use List::Util qw(max);
use File::Temp ();
use POSIX ();
+use IO::Handle (); # ->autoflush
sub new {
my (undef, $dir, $opt) = @_;
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;
};
}
sub set_sync_info {
my ($self, $oidhex, $folder, $id) = @_;
- _lms_rw($self)->set_src($oidhex, $folder, $id);
+ _lms_rw($self)->set_src(pack('H*', $oidhex), $folder, $id);
}
sub _remove_if_local { # git->cat_async arg
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
}
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);
}
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;
$self->ipc_lock_init("$dir/ipc.lock");
substr($dir, -length('/lei/store'), 10, '');
pipe(my ($r, $w)) or die "pipe: $!";
+ $w->autoflush(1);
# Mail we import into lei are private, so headers filtered out
# by -mda for public mail are not appropriate
local @PublicInbox::MDA::BAD_HEADERS = ();
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;