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 306431F9F3 for ; Fri, 16 Apr 2021 23:10:36 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/9] lei: expose share_path as a method Date: Fri, 16 Apr 2021 16:10:28 -0700 Message-Id: <20210416231035.31807-3-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: Since saved-searches aren't a part of lei/store, nor could it be considered cache data... (or can it? it is discardable, after all). --- lib/PublicInbox/LEI.pm | 6 ++++-- lib/PublicInbox/LeiSavedSearch.pm | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 4b87c104..52b588a2 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -83,13 +83,15 @@ sub rel2abs ($$) { File::Spec->rel2abs($p, $pwd); } -sub store_path ($) { +sub share_path ($) { # $HOME/.local/share/lei/$FOO my ($self) = @_; rel2abs($self, ($self->{env}->{XDG_DATA_HOME} // ($self->{env}->{HOME} // '/nonexistent').'/.local/share') - .'/lei/store'); + .'/lei'); } +sub store_path ($) { share_path($_[0]) . '/store' } + sub _config_path ($) { my ($self) = @_; rel2abs($self, ($self->{env}->{XDG_CONFIG_HOME} // diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm index e79cf76a..fe8301d6 100644 --- a/lib/PublicInbox/LeiSavedSearch.pm +++ b/lib/PublicInbox/LeiSavedSearch.pm @@ -23,7 +23,7 @@ sub new { return $lei->fail("$f non-existent or unreadable"); $self->{-cfg} = PublicInbox::Config::git_config_dump($f); } else { # new saved search "lei q --save" - my $saved_dir = $lei->store_path . '/../saved-searches/'; + my $saved_dir = $lei->share_path . '/saved-searches/'; my (@name) = ($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;