summaryrefslogtreecommitdiff
path: root/lib/MaildirIndexer/Index
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2020-01-25 16:25:20 +0000
committerdakkar <dakkar@thenautilus.net>2020-01-25 16:25:20 +0000
commite55f4624cf43a7da5e67706d2759a38298b327e7 (patch)
tree22cca5121fe86413984d71339a5db70142ea8cd6 /lib/MaildirIndexer/Index
parentsay where things went wrong (diff)
downloadMaildirIndexer-e55f4624cf43a7da5e67706d2759a38298b327e7.tar.gz
MaildirIndexer-e55f4624cf43a7da5e67706d2759a38298b327e7.tar.bz2
MaildirIndexer-e55f4624cf43a7da5e67706d2759a38298b327e7.zip
Revert "fewer temporary variables"
This reverts commit 314ee051c170c33d2c912b6750f916b73f9cb507. I think that the bug with LEAVE messes up return values inside Log::Timeline as well
Diffstat (limited to 'lib/MaildirIndexer/Index')
-rw-r--r--lib/MaildirIndexer/Index/ByAddresses.rakumod11
-rw-r--r--lib/MaildirIndexer/Index/ByRef.rakumod11
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/MaildirIndexer/Index/ByAddresses.rakumod b/lib/MaildirIndexer/Index/ByAddresses.rakumod
index 678254e..d420c3e 100644
--- a/lib/MaildirIndexer/Index/ByAddresses.rakumod
+++ b/lib/MaildirIndexer/Index/ByAddresses.rakumod
@@ -61,7 +61,7 @@ submethod account-for(Str @addresses,Str $mailbox,Int $step) {
}
method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) {
- MaildirIndexer::LogTimelineSchema::Index::Add.log: :class('ByAddresses'),:$mailbox, {
+ MaildirIndexer::LogTimelineSchema::Index::Add.log: :class('ByAddresses'),:$mailbox, -> {
# ignore adding the same file twice, files in maildirs are
# immutable
return if %!addresses-for-file{ $email.path }:exists;
@@ -76,7 +76,7 @@ method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) {
}
method del-path(IO:D $file, Str:D $mailbox --> Nil) {
- MaildirIndexer::LogTimelineSchema::Index::Rm.log: :class('ByAddresses'),:$mailbox, {
+ MaildirIndexer::LogTimelineSchema::Index::Rm.log: :class('ByAddresses'),:$mailbox, -> {
# using assignment would fail when the path isn't present in
# the hash, because it tries to assign the (undefined)
# Array[Str] as a single element, instead of splatting it;
@@ -107,12 +107,13 @@ submethod predict-mailbox-given-addresses(@addresses) {
}
method mailbox-for-email(MaildirIndexer::Email:D $email --> Str) {
- MaildirIndexer::LogTimelineSchema::Index::Find.log: :class('ByAddresses'), {
+ my Str $result;
+ MaildirIndexer::LogTimelineSchema::Index::Find.log: :class('ByAddresses'), -> {
my %prediction = self.predict-mailbox-given-addresses($email.addresses);
my @most-probable-mailboxes = %prediction.pairs.sort(*.value);
- if @most-probable-mailboxes -> $_ { return .[*-1].key }
- else { return Nil }
+ if @most-probable-mailboxes -> $_ { $result = .[*-1].key }
}
+ return $result;
}
diff --git a/lib/MaildirIndexer/Index/ByRef.rakumod b/lib/MaildirIndexer/Index/ByRef.rakumod
index 3a5ebdb..6e5b7f5 100644
--- a/lib/MaildirIndexer/Index/ByRef.rakumod
+++ b/lib/MaildirIndexer/Index/ByRef.rakumod
@@ -13,7 +13,7 @@ method dump() {
}
method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) {
- MaildirIndexer::LogTimelineSchema::Index::Add.log: :class('ByRef'),:$mailbox, {
+ MaildirIndexer::LogTimelineSchema::Index::Add.log: :class('ByRef'),:$mailbox, -> {
# ignore adding the same file twice, files in maildirs are
# immutable
return if %!id-for-file{ $email.path }:exists;
@@ -26,7 +26,7 @@ method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) {
}
method del-path(IO:D $file, Str:D $mailbox --> Nil) {
- MaildirIndexer::LogTimelineSchema::Index::Rm.log: :class('ByRef'),:$mailbox, {
+ MaildirIndexer::LogTimelineSchema::Index::Rm.log: :class('ByRef'),:$mailbox, -> {
my $id = %!id-for-file{ $file.path }:delete or return;
with %!mailboxes-for-id{ $id } -> $boxes {
$boxes{$mailbox}:delete;
@@ -36,10 +36,11 @@ method del-path(IO:D $file, Str:D $mailbox --> Nil) {
}
method mailbox-for-email(MaildirIndexer::Email:D $email --> Str) {
- MaildirIndexer::LogTimelineSchema::Index::Find.log: :class('ByRef'), {
+ my Str $result;
+ MaildirIndexer::LogTimelineSchema::Index::Find.log: :class('ByRef'), -> {
for |$email.refs() -> $ref {
- with %!mailboxes-for-id{$ref} { return .keys.sort.[0] }
+ with %!mailboxes-for-id{$ref} { $result = .keys.sort.[0] }
}
- return Nil;
}
+ return $result;
}