]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei q|up: fix write counter for v2
authorEric Wong <e@80x24.org>
Tue, 7 Sep 2021 22:41:41 +0000 (22:41 +0000)
committerEric Wong <e@80x24.org>
Wed, 8 Sep 2021 02:40:54 +0000 (02:40 +0000)
It's a bit confusing to see "0 written to ..." when we actually
wrote something.

lib/PublicInbox/LeiToMail.pm
t/lei-q-save.t

index 01f083844d136954b86efe48ddab689c5e953c9d..dbf58df9a21a2fcef96adafba6931810f4f63f12 100644 (file)
@@ -361,6 +361,7 @@ sub _v2_write_cb ($$) {
                $eml //= PublicInbox::Eml->new($bref);
                return if $dedupe && $dedupe->is_dup($eml, $smsg);
                $lei->{v2w}->ipc_do('add', $eml); # V2Writable->add
                $eml //= PublicInbox::Eml->new($bref);
                return if $dedupe && $dedupe->is_dup($eml, $smsg);
                $lei->{v2w}->ipc_do('add', $eml); # V2Writable->add
+               ++$lei->{-nr_write};
        }
 }
 
        }
 }
 
index 7aa9b84eb3d704d067410cf5a74f52641c34a9e7..743a7b70e5185a0ea0d88fe83d125bb2bd9a4138 100644 (file)
@@ -179,6 +179,8 @@ test_lei(sub {
        my (@before, @after);
        require PublicInbox::MboxReader;
        lei_ok(qw(q z:0.. -o), "v2:$v2");
        my (@before, @after);
        require PublicInbox::MboxReader;
        lei_ok(qw(q z:0.. -o), "v2:$v2");
+       like($lei_err, qr/^# ([1-9][0-9]*) written to \Q$v2\E/sm,
+               'non-zero write output to stderr');
        lei_ok(qw(q z:0.. -o), "mboxrd:$home/before", '--only', $v2, '-j1,1');
        open my $fh, '<', "$home/before";
        PublicInbox::MboxReader->mboxrd($fh, sub { push @before, $_[0] });
        lei_ok(qw(q z:0.. -o), "mboxrd:$home/before", '--only', $v2, '-j1,1');
        open my $fh, '<', "$home/before";
        PublicInbox::MboxReader->mboxrd($fh, sub { push @before, $_[0] });