X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FLEI.pm;h=053b6174d808514f04227b32f3bef982e72b3498;hp=41e761f8aabf939e81af2afb0b82bf7058b83e5e;hb=47d4e53734820b4e;hpb=7b7939d47b336fb7d8c4387858e620dbc218bb1e diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 41e761f8..053b6174 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1442,20 +1442,16 @@ sub refresh_watches { } # add all known Maildir folders as implicit watches - my $sto = $lei->_lei_store; - my $renames = 0; - if (my $lms = $sto ? $sto->search->lms : undef) { + my $lms = $lei->lms; + if ($lms) { + $lms->lms_write_prepare; for my $d ($lms->folders('maildir:')) { substr($d, 0, length('maildir:')) = ''; - my $cd = canonpath_harder($d); - my $f = "maildir:$cd"; # fixup old bugs while we're iterating: - if ($d ne $cd) { - $sto->ipc_do('lms_rename_folder', - "maildir:$d", $f); - ++$renames; - } + my $cd = canonpath_harder($d); + my $f = "maildir:$cd"; + $lms->rename_folder("maildir:$d", $f) if $d ne $cd; next if $watches->{$f}; # may be set to pause require PublicInbox::LeiWatch; $watches->{$f} = PublicInbox::LeiWatch->new($f); @@ -1463,7 +1459,6 @@ sub refresh_watches { add_maildir_watch($cd, $cfg_f); } } - $lei->sto_done_request if $renames; if ($old) { # cull old non-existent entries for my $url (keys %$old) { next if exists $seen{$url}; @@ -1490,13 +1485,12 @@ sub git_oid { git_sha(1, $eml); } -sub lms { # read-only LeiMailSync - my ($lei) = @_; - my $lse = $lei->{lse} // do { - my $sto = $lei->{sto} // _lei_store($lei); - $sto ? $sto->search : undef - }; - $lse ? $lse->lms : undef; +sub lms { + my ($lei, $rw) = @_; + my $sto = $lei->{sto} // _lei_store($lei) // return; + require PublicInbox::LeiMailSync; + my $f = "$sto->{priv_eidx}->{topdir}/mail_sync.sqlite3"; + (-f $f || $rw) ? PublicInbox::LeiMailSync->new($f) : undef; } sub sto_done_request { # only call this from lei-daemon process (not workers)