]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inboxwritable: add ->cleanup method
authorEric Wong <e@80x24.org>
Fri, 15 Nov 2019 09:50:39 +0000 (09:50 +0000)
committerEric Wong <e@80x24.org>
Sat, 16 Nov 2019 11:05:23 +0000 (11:05 +0000)
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
lib/PublicInbox/Xapcmd.pm
script/public-inbox-edit

index c73910acb30a754329bf5ce58e998a8775642b3f..d83912511451af8f5b14fc295616c88faa43ef1c 100644 (file)
@@ -257,4 +257,8 @@ sub umask_prepare {
        $self->{umask} = $umask;
 }
 
+sub cleanup ($) {
+       delete @{$_[0]}{qw(over mm git search)};
+}
+
 1;
index c807bf1014aef78d63f814ed17b4d7ead2840b00..77f0524e2b9a0fc42d67e935bc9309c735489d8f 100644 (file)
@@ -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);
index b437b3c0ac1f23c3408bb33e384b61623d5cea7c..1900b267fbaed598867dfd66917bad778a0c207f 100755 (executable)
@@ -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}) {