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 A7AE41F9F4 for ; Fri, 3 Sep 2021 08:54:27 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/8] lei: use lei->lms in place of lse->lms in a few places Date: Fri, 3 Sep 2021 08:54:23 +0000 Message-Id: <20210903085427.5541-5-e@80x24.org> In-Reply-To: <20210903085427.5541-1-e@80x24.org> References: <20210903085427.5541-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can golf out some code and refcounts this way. --- lib/PublicInbox/LeiInspect.pm | 3 +-- lib/PublicInbox/LeiPruneMailSync.pm | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm index 2d2ff1a0..2ade17af 100644 --- a/lib/PublicInbox/LeiInspect.pm +++ b/lib/PublicInbox/LeiInspect.pm @@ -206,8 +206,7 @@ sub lei_inspect { sub _complete_inspect { my ($lei, @argv) = @_; - my $sto = $lei->_lei_store or return; - my $lms = $sto->search->lms or return; + my $lms = $lei->lms or return; my $match_cb = $lei->complete_url_prepare(\@argv); map { $match_cb->($_) } $lms->folders; } diff --git a/lib/PublicInbox/LeiPruneMailSync.pm b/lib/PublicInbox/LeiPruneMailSync.pm index 79f3325d..98239a13 100644 --- a/lib/PublicInbox/LeiPruneMailSync.pm +++ b/lib/PublicInbox/LeiPruneMailSync.pm @@ -40,7 +40,7 @@ sub prune_imap { # lms->each_src callback sub input_path_url { # overrides PublicInbox::LeiInput::input_path_url my ($self, $input, @args) = @_; - my $lms = $self->{-lms_ro} //= $self->{lse}->lms; + my $lms = $self->{-lms_ro} //= $self->{lei}->lms; if ($input =~ /\Amaildir:(.+)/i) { my $mdir = $1; $lms->each_src($input, \&prune_mdir, $self, $mdir); @@ -59,24 +59,24 @@ sub lei_prune_mail_sync { my $sto = $lei->_lei_store or return $lei->fail(<search; - my $lms = $lse->lms or return $lei->fail(<{opt}->{all})) { - $lms->group2folders($lei, $all, \@folders) or return; + if (my $lms = $lei->lms) { + if (defined(my $all = $lei->{opt}->{all})) { + $lms->group2folders($lei, $all, \@folders) or return; + } else { + my $err = $lms->arg2folder($lei, \@folders); + $lei->qerr(@{$err->{qerr}}) if $err->{qerr}; + return $lei->fail($err->{fail}) if $err->{fail}; + } } else { - my $err = $lms->arg2folder($lei, \@folders); - $lei->qerr(@{$err->{qerr}}) if $err->{qerr}; - return $lei->fail($err->{fail}) if $err->{fail}; + return $lei->fail(<{dbh}; $sto->write_prepare($lei); - my $self = bless { lse => $lse }, __PACKAGE__; + my $self = bless {}, __PACKAGE__; $lei->{opt}->{'mail-sync'} = 1; # for prepare_inputs $self->prepare_inputs($lei, \@folders) or return; my $j = $lei->{opt}->{jobs} || scalar(@{$self->{inputs}}) || 1; - undef $lms; # for fork my $ops = {}; $sto->write_prepare($lei); $lei->{auth}->op_merge($ops, $self) if $lei->{auth};