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 21F571F934 for ; Mon, 19 Apr 2021 08:52:16 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/6] lei: support unlinked/missing saved searches Date: Mon, 19 Apr 2021 08:52:10 +0000 Message-Id: <20210419085215.14742-2-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: It's conceivable a user will want to erase all previous results but still rerun/refresh a search to get new results. We probably won't support prune functionality, here, and instead require explicit removal of saved searches. --- lib/PublicInbox/LeiSavedSearch.pm | 7 ++----- t/lei-q-save.t | 7 +++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm index d67622c9..94920a4e 100644 --- a/lib/PublicInbox/LeiSavedSearch.pm +++ b/lib/PublicInbox/LeiSavedSearch.pm @@ -61,11 +61,8 @@ sub list { bless $cfg, 'PublicInbox::Config'; my $out = $cfg->get_all('lei.q.output') or return (); map {; - if (s!\A(?:maildir|mh|mbox.+|mmdf):!!i) { - -e $_ ? $_ : (); # TODO auto-prune somewhere? - } else { # IMAP, maybe JMAP - $_; - } + s!\A(?:maildir|mh|mbox.+|mmdf):!!i; + $_; } @$out } diff --git a/t/lei-q-save.t b/t/lei-q-save.t index 761814b4..4e6ed642 100644 --- a/t/lei-q-save.t +++ b/t/lei-q-save.t @@ -67,5 +67,12 @@ test_lei(sub { lei_ok qw(_complete lei up); like($lei_out, qr!^\Q$home/mbcl2\E$!sm, 'complete got mbcl2 output'); like($lei_out, qr!^\Q$home/md/\E$!sm, 'complete got maildir output'); + + unlink("$home/mbcl2") or xbail "unlink $!"; + lei_ok qw(_complete lei up); + like($lei_out, qr!^\Q$home/mbcl2\E$!sm, + 'mbcl2 output shown despite unlink'); + lei_ok([qw(up mbcl2)], undef, { -C => $home, %$lei_opt }); + ok(-f "$home/mbcl2" && -s _ == 0, 'up recreates on missing output'); }); done_testing;