diff options
Diffstat (limited to 'lib/MaildirIndexer/Store.pm6')
-rw-r--r-- | lib/MaildirIndexer/Store.pm6 | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/MaildirIndexer/Store.pm6 b/lib/MaildirIndexer/Store.pm6 index 41dc314..5339bf3 100644 --- a/lib/MaildirIndexer/Store.pm6 +++ b/lib/MaildirIndexer/Store.pm6 @@ -1,5 +1,6 @@ use v6.d; unit class MaildirIndexer::Store; +use MaildirIndexer::LogTimelineSchema; use MaildirIndexer::Index; use MaildirIndexer::Parser; @@ -20,10 +21,14 @@ method start(--> Nil) { CATCH { warn .perl }; whenever $.file-channel -> $file { if $file.e && $file.f { - self.add-file($file); + MaildirIndexer::LogTimelineSchema::Store::Add.log: :file($file.path), -> { + self.add-file($file); + } } elsif !$file.e { - self.del-file($file); + MaildirIndexer::LogTimelineSchema::Store::Rm.log: :file($file.path), -> { + self.del-file($file); + } } } } @@ -33,7 +38,7 @@ method start(--> Nil) { method add-file(IO:D $file --> Nil) { my $mailbox = mailbox-from-path($file.path) or return; my $email = parse-email($file,:headers-only) or return; - CATCH { warn .perl }; + CATCH { warn $_ }; $!lock.protect: { .add-mail($email,$mailbox) for @!indices; } @@ -49,10 +54,13 @@ method del-file(IO:D $file --> Nil) { } method mailbox-for-email(MaildirIndexer::Email:D $email --> Str) { - for @!indices -> $index { - with $index.mailbox-for-email($email) { return $_ }; + my Str $result; + MaildirIndexer::LogTimelineSchema::Store::Find.log: { + for @!indices -> $index { + with $index.mailbox-for-email($email) { $result = $_; last }; + } } - return Nil; + return $result; } sub mailbox-from-path(Str() $path --> Str) { |