diff options
Diffstat (limited to 'lib/MaildirIndexer/Store.rakumod')
-rw-r--r-- | lib/MaildirIndexer/Store.rakumod | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/MaildirIndexer/Store.rakumod b/lib/MaildirIndexer/Store.rakumod index 27ec915..66ec086 100644 --- a/lib/MaildirIndexer/Store.rakumod +++ b/lib/MaildirIndexer/Store.rakumod @@ -19,18 +19,18 @@ method dump(--> Nil) { method start(--> Nil) { for ^$.workers { start react { - CATCH { warn $_ }; + CATCH { warn .gist }; whenever $.file-channel -> $file { when $file ~~ MaildirIndexer::ScanDir::End { MaildirIndexer::LogTimelineSchema::Scan::End.log(); } when $file ~~ :e & :f { - MaildirIndexer::LogTimelineSchema::Store::Add.log: :file($file.path), -> { + MaildirIndexer::LogTimelineSchema::Store::Add.log: :file($file.path), { self.add-file($file); } } when $file ~~ :!e { - MaildirIndexer::LogTimelineSchema::Store::Rm.log: :file($file.path), -> { + MaildirIndexer::LogTimelineSchema::Store::Rm.log: :file($file.path), { self.del-file($file); } } @@ -40,9 +40,9 @@ 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 $_ }; + my Str $mailbox = mailbox-from-path($file.path) or return; + my MaildirIndexer::Email $email = parse-email($file,:headers-only) or return; + CATCH { warn .gist; return }; $!lock.protect: { .add-mail($email,$mailbox) for @!indices; } @@ -58,15 +58,14 @@ method del-file(IO:D $file --> Nil) { } method mailbox-for-email(MaildirIndexer::Email:D $email --> Str) { - my Str $result; MaildirIndexer::LogTimelineSchema::Store::Find.log: { $!lock.protect: { for @!indices -> $index { - with $index.mailbox-for-email($email) { $result = $_; last }; + with $index.mailbox-for-email($email) { return $_ }; } } + return Nil; } - return $result; } sub mailbox-from-path(Str() $path --> Str) { |