From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 918071FA01 for ; Fri, 19 Feb 2021 12:09:57 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/6] net_reader: handle single-message IMAP mailboxes Date: Fri, 19 Feb 2021 05:09:53 -0700 Message-Id: <20210219120955.13891-5-e@80x24.org> In-Reply-To: <20210219120955.13891-1-e@80x24.org> References: <20210219120955.13891-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Due to an off-by-one error, we were unable to read mailboxes with only a single message of UID:1. Without this fix, the message with UID:1 could only be read after UID:2 was created; so there's no permanent data loss as long as a new message showed up. This affects all releases of public-inbox-watch with IMAP support, though it probably went unnoticed because single message inboxes are rare. --- lib/PublicInbox/NetReader.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm index 61ea538b..22ba4be7 100644 --- a/lib/PublicInbox/NetReader.pm +++ b/lib/PublicInbox/NetReader.pm @@ -353,17 +353,18 @@ sub _imap_fetch_all ($$$) { PublicInbox::IMAPTracker->new($url) : 0; my ($l_uidval, $l_uid) = $itrk ? $itrk->get_last : (); $l_uidval //= $r_uidval; # first time - $l_uid //= 1; + $l_uid //= 0; if ($l_uidval != $r_uidval) { return "E: $url UIDVALIDITY mismatch\n". "E: local=$l_uidval != remote=$r_uidval"; } my $r_uid = $r_uidnext - 1; - if ($l_uid != 1 && $l_uid > $r_uid) { + if ($l_uid > $r_uid) { return "E: $url local UID exceeds remote ($l_uid > $r_uid)\n". "E: $url strangely, UIDVALIDLITY matches ($l_uidval)\n"; } return if $l_uid >= $r_uid; # nothing to do + $l_uid ||= 1; warn "# $url fetching UID $l_uid:$r_uid\n" unless $self->{quiet}; $mic->Uid(1); # the default, we hope