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 325821F5AB for ; Fri, 15 Nov 2019 09:51:02 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 08/29] inboxwritable: add ->cleanup method Date: Fri, 15 Nov 2019 09:50:39 +0000 Message-Id: <20191115095100.25633-9-e@80x24.org> In-Reply-To: <20191115095100.25633-1-e@80x24.org> References: <20191115095100.25633-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We've been using this in -edit, and will be using it in some more scripts and tests to optimize for run_mode=2 with run_script. Keeping this in the *Writable modules since I don't see it being useful for the WWW and NNTP read-only interfaces which use PublicInbox::Inbox. --- lib/PublicInbox/InboxWritable.pm | 4 ++++ lib/PublicInbox/Xapcmd.pm | 2 +- script/public-inbox-edit | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm index c73910ac..d8391251 100644 --- a/lib/PublicInbox/InboxWritable.pm +++ b/lib/PublicInbox/InboxWritable.pm @@ -257,4 +257,8 @@ sub umask_prepare { $self->{umask} = $umask; } +sub cleanup ($) { + delete @{$_[0]}{qw(over mm git search)}; +} + 1; diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm index c807bf10..77f0524e 100644 --- a/lib/PublicInbox/Xapcmd.pm +++ b/lib/PublicInbox/Xapcmd.pm @@ -234,7 +234,7 @@ sub run { $im->lock_release; } - delete($ibx->{$_}) for (qw(mm over search)); # cleanup + $ibx->cleanup; process_queue(\@q, $cb, $max, $opt); $im->lock_acquire if !$opt->{-coarse_lock}; commit_changes($ibx, $im, $tmp, $opt); diff --git a/script/public-inbox-edit b/script/public-inbox-edit index b437b3c0..1900b267 100755 --- a/script/public-inbox-edit +++ b/script/public-inbox-edit @@ -57,7 +57,7 @@ sub find_mid ($$$) { my $tuple = [ $ibx, $smsg ]; push @{$found->{$cid} ||= []}, $tuple } - delete @$ibx{qw(over mm git search)}; # cleanup + PublicInbox::InboxWritable::cleanup($ibx); } $found; } @@ -131,7 +131,7 @@ foreach my $to_edit (values %$found) { my $edit_fn = $edit_fh->filename; my ($ibx, $smsg) = @{$to_edit->[0]}; my $old_raw = $ibx->msg_by_smsg($smsg); - delete @$ibx{qw(over mm git search)}; # cleanup + PublicInbox::InboxWritable::cleanup($ibx); my $tmp = $$old_raw; if (!$opt->{raw}) {