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 438F01F9F4 for ; Fri, 16 Apr 2021 23:10:36 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/9] lei: saved searches keyed only by path/URL and format Date: Fri, 16 Apr 2021 16:10:29 -0700 Message-Id: <20210416231035.31807-4-e@80x24.org> In-Reply-To: <20210416231035.31807-1-e@80x24.org> References: <20210416231035.31807-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We want users to be able to edit and refine the query over time while using the same output destination. --- lib/PublicInbox/LeiSavedSearch.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm index fe8301d6..ebc63091 100644 --- a/lib/PublicInbox/LeiSavedSearch.pm +++ b/lib/PublicInbox/LeiSavedSearch.pm @@ -10,9 +10,8 @@ use PublicInbox::OverIdx; use PublicInbox::LeiSearch; use PublicInbox::Config; use PublicInbox::Spawn qw(run_die); -use PublicInbox::ContentHash qw(content_hash git_sha); -use PublicInbox::Eml; -use PublicInbox::Hval qw(to_filename); +use PublicInbox::ContentHash qw(git_sha); +use Digest::SHA qw(sha256_hex); sub new { my ($cls, $lei, $dir) = @_; @@ -24,11 +23,11 @@ sub new { $self->{-cfg} = PublicInbox::Config::git_config_dump($f); } else { # new saved search "lei q --save" my $saved_dir = $lei->share_path . '/saved-searches/'; - my (@name) = ($lei->{ovv}->{dst} =~ m{([\w\-\.]+)/*\z}); + my (@n) = ($lei->{ovv}->{dst} =~ m{([\w\-\.]+)/*\z}); my $q = $lei->{mset_opt}->{q_raw} // die 'BUG: {q_raw} missing'; - my $q_raw_str = ref($q) ? "@$q" : $q; - push @name, to_filename($q_raw_str); - $dir = $saved_dir . join('-', @name); + push @n, sha256_hex("$lei->{ovv}->{fmt}\0$lei->{ovv}->{dst}"); + + $dir = $saved_dir . join('-', @n); require File::Path; File::Path::make_path($dir); # raises on error $self->{'-f'} = "$dir/lei.saved-search";