summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2019-12-27 16:27:36 +0000
committerdakkar <dakkar@thenautilus.net>2019-12-27 16:32:47 +0000
commit088c6b47216db3c1afe8ace88b1c02ded6f200a4 (patch)
treefc9242efa9525e4011d62d06f06b803674ab5ad1
parentskip non-mails based on name, first (diff)
downloadMaildirIndexer-088c6b47216db3c1afe8ace88b1c02ded6f200a4.tar.gz
MaildirIndexer-088c6b47216db3c1afe8ace88b1c02ded6f200a4.tar.bz2
MaildirIndexer-088c6b47216db3c1afe8ace88b1c02ded6f200a4.zip
some fixes after manual testing
-rw-r--r--lib/MaildirIndexer/Email.pm62
-rw-r--r--lib/MaildirIndexer/Index/ByRef.pm62
-rw-r--r--lib/MaildirIndexer/Parser.pm69
-rw-r--r--lib/MaildirIndexer/ScanDir.pm62
-rw-r--r--lib/MaildirIndexer/Store.pm64
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 {
<headers>
<separator>
@@ -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<utf8-c8>), path => $p.path);
+ return parse-email($p.slurp(:enc<utf8-c8>), 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;
}