This necessitated fixing pause_dedupe to release the handle
used by ->lock_for_scope_fast, but otherwise no changes to
the LeiToMail package.
---
 lib/PublicInbox/LeiSavedSearch.pm |  1 +
 t/lei-q-save.t                    | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/lib/PublicInbox/LeiSavedSearch.pm 
b/lib/PublicInbox/LeiSavedSearch.pm
index 948e4954..cd9effce 100644
--- a/lib/PublicInbox/LeiSavedSearch.pm
+++ b/lib/PublicInbox/LeiSavedSearch.pm
@@ -182,6 +182,7 @@ sub git { $_[0]->{ale}->git }
 sub pause_dedupe {
        my ($self) = @_;
        $self->{ale}->git->cleanup;
+       my $lockfh = delete $self->{lockfh}; # from lock_for_scope_fast;
        my $oidx = delete($self->{oidx}) // return;
        $oidx->commit_lazy;
 }
diff --git a/t/lei-q-save.t b/t/lei-q-save.t
index 5bc8fb74..c0c74581 100644
--- a/t/lei-q-save.t
+++ b/t/lei-q-save.t
@@ -84,6 +84,7 @@ test_lei(sub {
        lei_ok([qw(up mbcl2)], undef, { -C => $home, %$lei_opt });
        ok(-f "$home/mbcl2"  && -s _ == 0, 'up recreates on missing output');
 
+       # no --augment
        open my $mb, '>', "$home/mbrd" or xbail "open $!";
        print $mb $pre_existing;
        close $mb or xbail "close: $!";
@@ -92,8 +93,20 @@ test_lei(sub {
        open $mb, '<', "$home/mbrd" or xbail "open $!";
        is_deeply([grep(/pre-existing/, <$mb>)], [],
                'pre-existing messsage gone w/o augment');
+       close $mb;
        lei_ok(qw(q m:[email protected]));
        is(json_utf8->decode($lei_out)->[0]->{'s'},
                'pre-existing', '--save imported before clobbering');
+
+       # --augment
+       open $mb, '>', "$home/mbrd-aug" or xbail "open $!";
+       print $mb $pre_existing;
+       close $mb or xbail "close: $!";
+       lei_ok(qw(q -a --save -o mboxrd:mbrd-aug m:[email protected] -C), $home);
+       chdir($dh) or xbail "fchdir . $!";
+       open $mb, '<', "$home/mbrd-aug" or xbail "open $!";
+       $mb = do { local $/; <$mb> };
+       like($mb, qr/pre-existing/, 'pre-existing message preserved w/ -a');
+       like($mb, qr/<qp\@example\.com>/, 'new result written w/ -a');
 });
 done_testing;
--
unsubscribe: one-click, see List-Unsubscribe header
archive: https://public-inbox.org/meta/

Reply via email to