]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ExtSearchIdx.pm
ds: improve add_timer usability
[public-inbox.git] / lib / PublicInbox / ExtSearchIdx.pm
index c782a62a83b6330eda77818e30dea8531d90190d..a4b3bbd5e57c3255920e89e21b5e95e5a3d6116d 100644 (file)
@@ -29,7 +29,7 @@ use PublicInbox::V2Writable;
 use PublicInbox::InboxWritable;
 use PublicInbox::ContentHash qw(content_hash);
 use PublicInbox::Eml;
-use PublicInbox::DS qw(now);
+use PublicInbox::DS qw(now add_timer);
 use DBI qw(:sql_types); # SQL_BLOB
 
 sub new {
@@ -1003,8 +1003,7 @@ sub idx_init { # similar to V2Writable
        $self->with_umask(\&_idx_init, $self, $opt);
        $self->{oidx}->begin_lazy;
        $self->{oidx}->eidx_prep;
-       $self->git->batch_prepare;
-       $self->{midx}->begin_txn;
+       $self->{midx}->create_xdb if @new;
 }
 
 sub _watch_commit { # PublicInbox::DS::add_timer callback
@@ -1028,8 +1027,7 @@ sub on_inbox_unlock { # called by PublicInbox::InboxIdle
        $pr->("indexing $ekey\n") if $pr;
        $self->idx_init($opt);
        sync_inbox($self, $self->{-watch_sync}, $ibx);
-       $self->{-commit_timer} //= PublicInbox::DS::add_timer(
-                                       $opt->{'commit-interval'} // 10,
+       $self->{-commit_timer} //= add_timer($opt->{'commit-interval'} // 10,
                                        \&_watch_commit, $self);
 }