summaryrefslogtreecommitdiff
path: root/lib/MaildirIndexer/Index
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2019-12-27 17:18:10 +0000
committerdakkar <dakkar@thenautilus.net>2019-12-27 17:18:10 +0000
commit42d176c71218f2daac666ce3f254356b8798dc68 (patch)
tree1438f8562c04328fd04e1d09bea8b23df9cf0340 /lib/MaildirIndexer/Index
parenttypes in Store (diff)
downloadMaildirIndexer-42d176c71218f2daac666ce3f254356b8798dc68.tar.gz
MaildirIndexer-42d176c71218f2daac666ce3f254356b8798dc68.tar.bz2
MaildirIndexer-42d176c71218f2daac666ce3f254356b8798dc68.zip
Log::Timeline
apparently reading from the socket is the slowest bit
Diffstat (limited to 'lib/MaildirIndexer/Index')
-rw-r--r--lib/MaildirIndexer/Index/ByRef.pm634
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;
}