]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiStore.pm
lei_input: set and prepare watches early
[public-inbox.git] / lib / PublicInbox / LeiStore.pm
index 0652137e8f06d5ffc0272ae8d356486d60bb6021..0fa2d3c08ba901e12f0900786f6bd9a3fab18e9d 100644 (file)
@@ -202,7 +202,7 @@ sub _lms_rw ($) {
                require PublicInbox::LeiMailSync;
                my $f = "$self->{priv_eidx}->{topdir}/mail_sync.sqlite3";
                my $lms = PublicInbox::LeiMailSync->new($f);
-               $lms->lms_begin;
+               $lms->lms_write_prepare;
                $lms;
        };
 }
@@ -243,8 +243,8 @@ sub remove_docids ($;@) {
        my $eidx = eidx_init($self);
        for my $docid (@docids) {
                $eidx->idx_shard($docid)->ipc_do('xdb_remove', $docid);
-               $self->{oidx}->delete_by_num($docid);
-               $self->{oidx}->{dbh}->do(<<EOF, undef, $docid);
+               $eidx->{oidx}->delete_by_num($docid);
+               $eidx->{oidx}->{dbh}->do(<<EOF, undef, $docid);
 DELETE FROM xref3 WHERE docid = ?
 EOF
        }
@@ -450,9 +450,7 @@ sub checkpoint {
        if (my $im = $self->{im}) {
                $wait ? $im->barrier : $im->checkpoint;
        }
-       if (my $lms = delete $self->{lms}) {
-               $lms->lms_commit;
-       }
+       delete $self->{lms};
        $self->{priv_eidx}->checkpoint($wait);
 }
 
@@ -481,9 +479,7 @@ sub done {
                        warn $err;
                }
        }
-       if (my $lms = delete $self->{lms}) {
-               $lms->lms_commit;
-       }
+       delete $self->{lms};
        $self->{priv_eidx}->done; # V2Writable::done
        xchg_stderr($self);
        die $err if $err;
@@ -541,4 +537,11 @@ sub git_blob_id { # called via LEI->git_blob_id
        git_sha(1, $eml)->hexdigest;
 }
 
+# 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;