From 3b97aa0df99bcad2656899c03ee1f759cb3efc55 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 9 Nov 2018 15:19:16 +0000 Subject: in-memory store, and Email class --- bayes | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'bayes') diff --git a/bayes b/bayes index c7c81bf..0843976 100644 --- a/bayes +++ b/bayes @@ -2,21 +2,31 @@ use v6.d.PREVIEW; use lib 'lib'; use MaildirIndexer::ScanDir; -use MaildirIndexer::Parser; +use MaildirIndexer::Store; sub MAIN($maildir) { + my $store = MaildirIndexer::Store.new; + my $file-supply = scan-dir($maildir); my $file-channel = $file-supply.Channel; + for ^10 { start react { whenever $file-channel -> $file { if $file.e && $file.f { - my $email = parse-email($file,:headers-only); - say "{$file} - {$email}"; + $store.add-file($file); + } + elsif !$file.e { + $store.del-file($file); } } } } - react whenever signal(SIGINT) { exit } + react { + whenever signal(SIGINT) { exit } + whenever signal(SIGHUP) { + $store.dump(); + } + } } -- cgit v1.2.3