summaryrefslogtreecommitdiff
path: root/lib/MaildirIndexer/Store.rakumod
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2020-01-25 15:35:02 +0000
committerdakkar <dakkar@thenautilus.net>2020-01-25 15:38:23 +0000
commit314ee051c170c33d2c912b6750f916b73f9cb507 (patch)
tree8b5ed72f69791d17d7d2f5e0ed83cb03f152f8b3 /lib/MaildirIndexer/Store.rakumod
parentnicer scan-dir signature (diff)
downloadMaildirIndexer-314ee051c170c33d2c912b6750f916b73f9cb507.tar.gz
MaildirIndexer-314ee051c170c33d2c912b6750f916b73f9cb507.tar.bz2
MaildirIndexer-314ee051c170c33d2c912b6750f916b73f9cb507.zip
fewer temporary variables
we can `return` from an inner block, even when that block is executed somewhere else: `return` is lexical!
Diffstat (limited to 'lib/MaildirIndexer/Store.rakumod')
-rw-r--r--lib/MaildirIndexer/Store.rakumod17
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) {