-sub lms { # read-only LeiMailSync
- my ($lei) = @_;
- my $lse = $lei->{lse} // do {
- my $sto = $lei->{sto} // _lei_store($lei);
- $sto ? $sto->search : undef
+sub lms {
+ my ($lei, $creat) = @_;
+ my $sto = $lei->{sto} // _lei_store($lei) // return;
+ require PublicInbox::LeiMailSync;
+ my $f = "$sto->{priv_eidx}->{topdir}/mail_sync.sqlite3";
+ (-f $f || $creat) ? PublicInbox::LeiMailSync->new($f) : undef;
+}
+
+sub sto_done_request {
+ my ($lei, $wq) = @_;
+ return unless $lei->{sto};
+ local $current_lei = $lei;
+ my $sock = $wq ? $wq->{lei_sock} : undef;
+ eval {
+ if ($sock //= $lei->{sock}) { # issue, async wait
+ $lei->{sto}->wq_io_do('done', [ $sock ]);
+ } else { # forcibly wait
+ my $wait = $lei->{sto}->wq_do('done');
+ }