From 5b4fde37adefa37508d131dbe013353ef3345051 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 19 Jul 2021 08:59:35 +0000 Subject: lei: start implementing inotify Maildir support This allows lei to automatically note keyword (message flag) changes made to a Maildir and propagate it into lei/store: lei add-watch --state=tag-ro /path/to/Maildir This doesn't persist across restarts, yet. In the future, it will be applied automatically to "lei q" output Maildirs by default (with an option to disable it). State values of tag-rw, index-, import- will all be supported for Maildir. This represents a fairly major internal change that's fairly intrusive, but the whole daemon-oriented design was to facilitate being able to automatically monitor (and propagate) Maildir/IMAP flag changes. --- lib/PublicInbox/DirIdle.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/PublicInbox/DirIdle.pm') diff --git a/lib/PublicInbox/DirIdle.pm b/lib/PublicInbox/DirIdle.pm index 5142d005..7031e5fd 100644 --- a/lib/PublicInbox/DirIdle.pm +++ b/lib/PublicInbox/DirIdle.pm @@ -53,6 +53,23 @@ sub new { $self; } +sub add_watches { + my ($self, $dirs, $gone) = @_; + my $fl = $MAIL_IN | ($gone ? $MAIL_GONE : 0); + for my $d (@$dirs) { + $self->{inot}->watch($d, $fl); + } + PublicInbox::FakeInotify::poll_once($self) if !$ino_cls; +} + +sub rm_watches { + my ($self, $dir) = @_; + my $inot = $self->{inot}; + if (my $cb = $inot->can('rm_watches')) { # TODO for fake watchers + $cb->($inot, $dir); + } +} + sub event_step { my ($self) = @_; my $cb = $self->{cb}; -- cgit v1.2.3-24-ge0c7