diff options
author | Eric Wong <e@80x24.org> | 2021-09-18 09:33:25 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-09-18 20:25:27 +0000 |
commit | 47d4e53734820b4e5a2f6cfa29056329e387ef22 (patch) | |
tree | 78328c0d68e3e329fa8c57c3300f8273bc122b89 /lib/PublicInbox/LeiStore.pm | |
parent | 7b7939d47b336fb7d8c4387858e620dbc218bb1e (diff) | |
download | public-inbox-47d4e53734820b4e5a2f6cfa29056329e387ef22.tar.gz |
Since 44917fdd24a8bec1 ("lei_mail_sync: do not use transactions"), relying on lei/store to serialize access was a pointless endeavor. Rely on flock(2) to serialize multiple writers since (in my experience) it's the easiest way to deal with parallel writers when using SQLite. This allows us to simplify existing callers while speeding up 'lei refresh-mail-sync --all=local' by 5% or so.
Diffstat (limited to 'lib/PublicInbox/LeiStore.pm')
-rw-r--r-- | lib/PublicInbox/LeiStore.pm | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm index 32f55abd..08add8f5 100644 --- a/lib/PublicInbox/LeiStore.pm +++ b/lib/PublicInbox/LeiStore.pm @@ -190,7 +190,7 @@ sub export1_kw_md ($$$$$) { syslog('warning', "unlink($src): $!"); } # TODO: verify oidbin? - lms_mv_src($self, "maildir:$mdir", + $self->{lms}->mv_src("maildir:$mdir", $oidbin, \$orig, $bn); return; } elsif ($! == EEXIST) { # lost race with "lei export-kw"? @@ -200,7 +200,7 @@ sub export1_kw_md ($$$$$) { } } for (@try) { return if -e "$mdir/$_/$orig" }; - lms_clear_src($self, "maildir:$mdir", \$orig); + $self->{lms}->clear_src("maildir:$mdir", \$orig); } sub sto_export_kw ($$$) { @@ -255,7 +255,7 @@ sub remove_eml_vmd { # remove just the VMD \@docids; } -sub _lms_rw ($) { +sub _lms_rw ($) { # it is important to have eidx processes open before lms my ($self) = @_; my ($eidx, $tl) = eidx_init($self); $self->{lms} //= do { @@ -267,37 +267,11 @@ sub _lms_rw ($) { }; } -sub lms_clear_src { - my ($self, $folder, $id) = @_; - _lms_rw($self)->clear_src($folder, $id); -} - -sub lms_mv_src { - my ($self, $folder, $oidbin, $id, $newbn) = @_; - _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 lms_rename_folder { - my ($self, $old, $new) = @_; - _lms_rw($self)->rename_folder($old, $new); -} - sub set_sync_info { my ($self, $oidhex, $folder, $id) = @_; _lms_rw($self)->set_src(pack('H*', $oidhex), $folder, $id); } -sub lms_set_src { - my ($self, $oidbin, $folder, $id) = @_; - _lms_rw($self)->set_src($oidbin, $folder, $id); -} - sub _remove_if_local { # git->cat_async arg my ($bref, $oidhex, $type, $size, $self) = @_; $self->{im}->remove($bref) if $bref; @@ -608,11 +582,4 @@ sub write_prepare { $lei->{sto} = $self; } -# called by lei-daemon before lei->refresh_watches -sub add_sync_folders { - my ($self, @folders) = @_; - my $lms = _lms_rw($self); - for my $f (@folders) { $lms->fid_for($f, 1) } -} - 1; |