diff options
Diffstat (limited to 'lib/MaildirIndexer/Index/ByRef.pm6')
-rw-r--r-- | lib/MaildirIndexer/Index/ByRef.pm6 | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/MaildirIndexer/Index/ByRef.pm6 b/lib/MaildirIndexer/Index/ByRef.pm6 index 5a9b53b..d044272 100644 --- a/lib/MaildirIndexer/Index/ByRef.pm6 +++ b/lib/MaildirIndexer/Index/ByRef.pm6 @@ -1,6 +1,7 @@ use v6.d; use MaildirIndexer::Index; unit class MaildirIndexer::Index::ByRef does MaildirIndexer::Index; +use MaildirIndexer::LogTimelineSchema; use MaildirIndexer::Email; has Str %!id-for-file; @@ -12,25 +13,32 @@ method dump() { } method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) { - my $id = $email.message-id or return; - %!id-for-file{ $email.path } = $id; - %!mailboxes-for-id{ $id }.push($mailbox); - return; + MaildirIndexer::LogTimelineSchema::Index::Add.log: :class('ByRef'),:$mailbox, -> { + my $id = $email.message-id or return; + %!id-for-file{ $email.path } = $id; + %!mailboxes-for-id{ $id }.push($mailbox); + return; + } } method del-path(IO:D $file, Str:D $mailbox --> Nil) { - my $id = %!id-for-file{ $file.path }:delete; - with %!mailboxes-for-id{ $id } { - with .grep($mailbox):k -> $pos { - .splice($pos,1); - } + MaildirIndexer::LogTimelineSchema::Index::Rm.log: :class('ByRef'),:$mailbox, -> { + my $id = %!id-for-file{ $file.path }:delete; + with %!mailboxes-for-id{ $id } { + with .grep($mailbox):k -> $pos { + .splice($pos,1); + } + } + return; } - return; } method mailbox-for-email(MaildirIndexer::Email:D $email --> Str) { - for |$email.refs() -> $ref { - with %!mailboxes-for-id{$ref} { return .[*-1] } + my Str $result; + MaildirIndexer::LogTimelineSchema::Index::Find.log: :class('ByRef'), -> { + for |$email.refs() -> $ref { + with %!mailboxes-for-id{$ref} { $result = .[*-1] } + } } - return Nil; + return $result; } |