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 8D40F1F9F3 for ; Tue, 17 Aug 2021 08:52:42 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/3] lei forget-mail-sync: rely on lei/store process Date: Tue, 17 Aug 2021 08:52:41 +0000 Message-Id: <20210817085241.25592-4-e@80x24.org> In-Reply-To: <20210817085241.25592-1-e@80x24.org> References: <20210817085241.25592-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: As implied in commit 6ff03ba2be9247f1 ("lei export-kw: do not write directly to mail_sync.sqlite3"), modifying mail_sync.sqlite3 directly can lead to conflicts and making everything go through lei/store is easier. --- lib/PublicInbox/LeiForgetMailSync.pm | 8 ++++---- lib/PublicInbox/LeiStore.pm | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LeiForgetMailSync.pm b/lib/PublicInbox/LeiForgetMailSync.pm index c74ba25d..940ca1b6 100644 --- a/lib/PublicInbox/LeiForgetMailSync.pm +++ b/lib/PublicInbox/LeiForgetMailSync.pm @@ -15,13 +15,13 @@ use PublicInbox::LeiExportKw; sub lei_forget_mail_sync { my ($lei, @folders) = @_; my $lms = $lei->lms or return; + my $sto = $lei->_lei_store or return; # may disappear due to race + $sto->write_prepare; my $err = $lms->arg2folder($lei, \@folders); $lei->qerr(@{$err->{qerr}}) if $err->{qerr}; return $lei->fail($err->{fail}) if $err->{fail}; - delete $lms->{dbh}; - $lms->lms_begin; - $lms->forget_folder($_) for @folders; - $lms->lms_commit; + $sto->ipc_do('lms_forget_folders', @folders); + my $wait = $sto->ipc_do('done'); } *_complete_forget_mail_sync = \&PublicInbox::LeiExportKw::_complete_export_kw; diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm index 3f33d114..e8334187 100644 --- a/lib/PublicInbox/LeiStore.pm +++ b/lib/PublicInbox/LeiStore.pm @@ -216,6 +216,12 @@ sub lms_mv_src { _lms_rw($self)->mv_src($folder, $oidbin, $id, $newbn); } +sub lms_forget_folders { + my ($self, @folders) = @_; + my $lms = _lms_rw($self); + for my $f (@folders) { $lms->forget_folder($f) } +} + sub set_sync_info { my ($self, $oidhex, $folder, $id) = @_; _lms_rw($self)->set_src($oidhex, $folder, $id);