about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiNoteEvent.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-02 10:17:58 +0000
committerEric Wong <e@80x24.org>2021-09-02 21:22:50 +0000
commit4166c482b710acea785063de2c69a8a370c6d373 (patch)
treeb6dfb983908d485b66f6e6140b45f71a6fcae251 /lib/PublicInbox/LeiNoteEvent.pm
parent4f9c44e3fff9c413fc54050dcc633692d33f6968 (diff)
downloadpublic-inbox-4166c482b710acea785063de2c69a8a370c6d373.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/LeiNoteEvent.pm')
-rw-r--r--lib/PublicInbox/LeiNoteEvent.pm14
1 files changed, 7 insertions, 7 deletions
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
 }