From 088c6b47216db3c1afe8ace88b1c02ded6f200a4 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 27 Dec 2019 16:27:36 +0000 Subject: some fixes after manual testing --- lib/MaildirIndexer/Email.pm6 | 2 +- lib/MaildirIndexer/Index/ByRef.pm6 | 2 +- lib/MaildirIndexer/Parser.pm6 | 9 +++++---- lib/MaildirIndexer/ScanDir.pm6 | 2 +- lib/MaildirIndexer/Store.pm6 | 4 +++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/MaildirIndexer/Email.pm6 b/lib/MaildirIndexer/Email.pm6 index d5ecc18..f3c04dd 100644 --- a/lib/MaildirIndexer/Email.pm6 +++ b/lib/MaildirIndexer/Email.pm6 @@ -1,7 +1,7 @@ use v6.d.PREVIEW; unit class MaildirIndexer::Email; -has IO $!path; +has IO $.path; has %!headers; has $!body; diff --git a/lib/MaildirIndexer/Index/ByRef.pm6 b/lib/MaildirIndexer/Index/ByRef.pm6 index 497b5a1..5a9b53b 100644 --- a/lib/MaildirIndexer/Index/ByRef.pm6 +++ b/lib/MaildirIndexer/Index/ByRef.pm6 @@ -4,7 +4,7 @@ unit class MaildirIndexer::Index::ByRef does MaildirIndexer::Index; use MaildirIndexer::Email; has Str %!id-for-file; -has Str %!mailboxes-for-id; +has Array[Str] %!mailboxes-for-id; method dump() { say "{.key} → {.value}" for %!id-for-file; diff --git a/lib/MaildirIndexer/Parser.pm6 b/lib/MaildirIndexer/Parser.pm6 index e6be32f..a193f75 100644 --- a/lib/MaildirIndexer/Parser.pm6 +++ b/lib/MaildirIndexer/Parser.pm6 @@ -9,7 +9,7 @@ my @separators = ( "\x0d\x0d", ); -grammar Message { +my grammar Message { regex TOP { @@ -37,7 +37,7 @@ grammar Message { token junk { \N+ } } -class Message-actions { +my class Message-actions { has $.path = IO; method TOP($/) { make MaildirIndexer::Email.new( @@ -58,7 +58,7 @@ class Message-actions { } multi parse-email(IO::Path:D $p --> MaildirIndexer::Email) is export { - return parse-email($p.slurp(:enc), path => $p.path); + return parse-email($p.slurp(:enc), path => $p); } multi parse-email(IO::Path:D $p, :$headers-only! --> MaildirIndexer::Email) is export { @@ -68,7 +68,7 @@ multi parse-email(IO::Path:D $p, :$headers-only! --> MaildirIndexer::Email) is e :nl-in(@separators), :!chomp, )[0], - path => $p.path, + path => $p, ); } @@ -84,6 +84,7 @@ multi parse-email(IO::Socket::Async:D $s --> MaildirIndexer::Email) is export { } multi parse-email(Str:D $email-str, :$path = IO --> MaildirIndexer::Email) is export { + CATCH { warn .perl; return Nil }; with Message.parse($email-str,:actions(Message-actions.new(:$path))) { return .made; } diff --git a/lib/MaildirIndexer/ScanDir.pm6 b/lib/MaildirIndexer/ScanDir.pm6 index d3e5070..e0e2d77 100644 --- a/lib/MaildirIndexer/ScanDir.pm6 +++ b/lib/MaildirIndexer/ScanDir.pm6 @@ -8,7 +8,7 @@ sub scan-dir(IO() $path --> Supply) is export { sub add-dir(IO::Path $dir, :$initial) { %watched-dirs{$dir} = True; - CATCH { when X::IO::Dir { }; default { .perl.say } } + CATCH { when X::IO::Dir { }; default { warn .perl } } whenever $dir.watch { my $path-io = .path.IO; diff --git a/lib/MaildirIndexer/Store.pm6 b/lib/MaildirIndexer/Store.pm6 index 2c60233..dbe2343 100644 --- a/lib/MaildirIndexer/Store.pm6 +++ b/lib/MaildirIndexer/Store.pm6 @@ -17,6 +17,7 @@ method dump() { method start() { for ^10 { start react { + CATCH { warn .perl }; whenever $.file-channel -> $file { if $file.e && $file.f { self.add-file($file); @@ -31,7 +32,8 @@ method start() { method add-file(IO:D $file) { my $mailbox = mailbox-from-path($file.path) or return; - my $email = parse-email($file,:headers-only); + my $email = parse-email($file,:headers-only) or return; + CATCH { warn .perl }; $!lock.protect: { .add-mail($email,$mailbox) for @!indices; } -- cgit v1.2.3