]> Sergey Matveev's repositories - public-inbox.git/commitdiff
net_reader: NNTP: remove article numbers from mail_sync folders
authorEric Wong <e@80x24.org>
Sun, 19 Sep 2021 22:51:57 +0000 (17:51 -0500)
committerEric Wong <e@80x24.org>
Sun, 19 Sep 2021 22:52:45 +0000 (22:52 +0000)
NNTP article numbers are stored separately from folder names
in mail_sync.sqlite3.

Recovering from this is optional, worse case is wasting
bandwidth refetching some messages.  To (optionally) recover
from this, use:

lei forget-mail-sync $URL_WITH_ARTNUMS

Some articles will be refetched on the next import, but
duplicate data won't be indexed in Xapian.

lib/PublicInbox/NetReader.pm
t/lei-import-nntp.t

index fbe1ac4fa726b4ac1bc44e84d63f667d3275902e..eab7320e913aefc9441c63cb4b0b1bf441f30996 100644 (file)
@@ -729,7 +729,10 @@ sub _nntp_fetch_all ($$$) {
        }
        (defined($num_a) && defined($num_b) && $num_a > $num_b) and
                return "E: $uri: backwards range: $num_a > $num_b";
-
+       if (defined($num_a)) { # no article numbers in mail_sync.sqlite3
+               $uri = $uri->clone;
+               $uri->group($group);
+       }
        # IMAPTracker is also used for tracking NNTP, UID == article number
        # LIST.ACTIVE can get the equivalent of UIDVALIDITY, but that's
        # expensive.  So we assume newsgroups don't change:
index 1eb41e0ed2f9425d60333c46792f8781ba5a031a..df0594d43c6748e460975a3a38854c6c722f6d9c 100644 (file)
@@ -49,12 +49,16 @@ test_lei({ tmpdir => $tmpdir }, sub {
 
        my $end = $high - 1;
        lei_ok qw(import), "$url/$high";
+       lei_ok 'ls-mail-sync';
+       is($lei_out, "$url\n", 'article number not stored as folder');
        lei_ok qw(q z:0..); my $one = json_utf8->decode($lei_out);
        pop @$one; # trailing null
        is(scalar(@$one), 1, 'only 1 result');
 
        local $ENV{HOME} = "$tmpdir/h3";
        lei_ok qw(import), "$url/$low-$end";
+       lei_ok 'ls-mail-sync';
+       is($lei_out, "$url\n", 'article range not stored as folder');
        lei_ok qw(q z:0..); my $start = json_utf8->decode($lei_out);
        pop @$start; # trailing null
        is(scalar(@$start), scalar(map { $_ } ($low..$end)),