diff options
author | dakkar <dakkar@thenautilus.net> | 2020-01-25 16:25:20 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2020-01-25 16:25:20 +0000 |
commit | e55f4624cf43a7da5e67706d2759a38298b327e7 (patch) | |
tree | 22cca5121fe86413984d71339a5db70142ea8cd6 /lib/MaildirIndexer/Parser.rakumod | |
parent | say where things went wrong (diff) | |
download | MaildirIndexer-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/Parser.rakumod')
-rw-r--r-- | lib/MaildirIndexer/Parser.rakumod | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/MaildirIndexer/Parser.rakumod b/lib/MaildirIndexer/Parser.rakumod index 7623d17..d30ca86 100644 --- a/lib/MaildirIndexer/Parser.rakumod +++ b/lib/MaildirIndexer/Parser.rakumod @@ -61,32 +61,34 @@ my class Message-actions { } multi parse-email(IO::Path:D $p --> MaildirIndexer::Email) is export { - MaildirIndexer::LogTimelineSchema::Parse::Email::File.log: :file($p.path), { + my MaildirIndexer::Email $result; + MaildirIndexer::LogTimelineSchema::Parse::Email::File.log: :file($p.path), -> { # as of 2019,11, `slurp` replaces all \r\n with \n ?? - return parse-email($p.slurp(:enc<utf8-c8>), path => $p); + $result = parse-email($p.slurp(:enc<utf8-c8>), path => $p); } + return $result; } multi parse-email(IO::Path:D $p, :$headers-only! --> MaildirIndexer::Email) is export { - # due to a bug, we can't put that LEAVE inside the inner block; - # see https://github.com/rakudo/rakudo/issues/2380 - my IO::Handle $h; LEAVE { .close with $h }; - MaildirIndexer::LogTimelineSchema::Parse::Email::File.log: :file($p.path), { - $h = $p.open( + my MaildirIndexer::Email $result; + MaildirIndexer::LogTimelineSchema::Parse::Email::File.log: :file($p.path), -> { + my IO::Handle $h = $p.open( :enc<utf8-c8>, :nl-in(@separators), :!chomp, ); - return parse-email( + $result = parse-email( $h.lines()[0], path => $p, ); + $h.close(); } + return $result; } multi parse-email(IO::Socket::Async:D $s --> MaildirIndexer::Email) is export { - MaildirIndexer::LogTimelineSchema::Parse::Email::Socket.log: { - my MaildirIndexer::Email $result; + my MaildirIndexer::Email $result; + MaildirIndexer::LogTimelineSchema::Parse::Email::Socket.log: -> { my $string; react { whenever $s.Supply(:enc<utf8-c8>) { @@ -98,18 +100,17 @@ multi parse-email(IO::Socket::Async:D $s --> MaildirIndexer::Email) is export { QUIT { done }; } } - return $result; } + return $result; } multi parse-email(Str:D $email-str, :$path = IO --> MaildirIndexer::Email) is export { - MaildirIndexer::LogTimelineSchema::Parse::Email::Str.log: { - CATCH { return .fail }; + my MaildirIndexer::Email $result; + MaildirIndexer::LogTimelineSchema::Parse::Email::Str.log: -> { + CATCH { warn $_; return Nil }; with Message.parse($email-str,:actions(Message-actions.new(:$path))) { - return .made; - } - else { - return Nil; + $result = .made; } } + return $result; } |