From 4166c482b710acea785063de2c69a8a370c6d373 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 2 Sep 2021 10:17:58 +0000 Subject: lei: propagate keyword changes from lei/store This works with existing inotify/EVFILT_VNODE functionality to propagate changes made from one Maildir to another Maildir. I chose the lei/store worker process to handle this since propagating changes back into lei-daemon on a massive scale could lead to dead-locking while both processes are attempting to write to each other. Eliminating IPC overhead is a nice side effect, but could hurt performance if Maildirs are slow. The code for "lei export-kw" is significantly revamped to match the new code used in the "lei/store" daemon. It should be more correct w.r.t. corner-cases and stale entries, but perhaps better tests need to be written. squashed: t/lei-auto-watch: increase delay for FreeBSD kevent My FreeBSD VM seems to need longer for this test than inotify under Linux, likely because the kevent support code needs to be more complicated. --- lib/PublicInbox/LeiNoteEvent.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/LeiNoteEvent.pm') diff --git a/lib/PublicInbox/LeiNoteEvent.pm b/lib/PublicInbox/LeiNoteEvent.pm index 6a40ba39..41415346 100644 --- a/lib/PublicInbox/LeiNoteEvent.pm +++ b/lib/PublicInbox/LeiNoteEvent.pm @@ -36,32 +36,31 @@ sub note_event_arm_done ($) { } sub eml_event ($$$$) { - my ($self, $eml, $kw, $state) = @_; + my ($self, $eml, $vmd, $state) = @_; my $sto = $self->{lei}->{sto}; my $lse = $self->{lse} //= $sto->search; - my $vmd = { kw => $kw }; if ($state =~ /\Aimport-(?:rw|ro)\z/) { $sto->ipc_do('set_eml', $eml, $vmd); } elsif ($state =~ /\Aindex-(?:rw|ro)\z/) { my $xoids = $self->{lei}->ale->xoids_for($eml); $sto->ipc_do('index_eml_only', $eml, $vmd, $xoids); } elsif ($state =~ /\Atag-(?:rw|ro)\z/) { - my $c = $lse->kw_changed($eml, $kw, my $docids = []); + my $c = $lse->kw_changed($eml, $vmd->{kw}, my $docids = []); if (scalar @$docids) { # already in lei/store $sto->ipc_do('set_eml_vmd', undef, $vmd, $docids) if $c; } elsif (my $xoids = $self->{lei}->ale->xoids_for($eml)) { # it's in an external, only set kw, here $sto->ipc_do('set_xvmd', $xoids, $eml, $vmd); - } # else { totally unknown + } # else { totally unknown: ignore } else { warn "unknown state: $state (in $self->{lei}->{cfg}->{'-f'})\n"; } } sub maildir_event { # via wq_io_do - my ($self, $fn, $kw, $state) = @_; + my ($self, $fn, $vmd, $state) = @_; my $eml = PublicInbox::InboxWritable::eml_from_path($fn) // return; - eml_event($self, $eml, $kw, $state); + eml_event($self, $eml, $vmd, $state); } sub lei_note_event { @@ -98,7 +97,8 @@ sub lei_note_event { // return; return if index($fl, 'T') >= 0; my $kw = PublicInbox::MdirReader::flags2kw($fl); - $self->wq_io_do('maildir_event', [], $fn, $kw, $state); + my $vmd = { kw => $kw, sync_info => [ $folder, \$bn ] }; + $self->wq_io_do('maildir_event', [], $fn, $vmd, $state); } # else: TODO: imap } -- cgit v1.2.3-24-ge0c7