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-ASN: 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 9FA1B1FA17 for ; Mon, 19 Apr 2021 08:52:16 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/6] lei q: --save and --augment may be combined Date: Mon, 19 Apr 2021 08:52:15 +0000 Message-Id: <20210419085215.14742-7-e@80x24.org> In-Reply-To: <20210419085215.14742-1-e@80x24.org> References: <20210419085215.14742-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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:import-before@example.com)); 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:qp@example.com -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//, 'new result written w/ -a'); }); done_testing;