From 99082038ec300153591376f700d5884b31293031 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Sun, 15 Jun 2014 08:41:04 +0200 Subject: Replace RMail by Mail. This also reduces the handling we have to do ourselves. --- lib/feed2imap/maildir.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/feed2imap/maildir.rb') diff --git a/lib/feed2imap/maildir.rb b/lib/feed2imap/maildir.rb index 7335f03..68d591f 100644 --- a/lib/feed2imap/maildir.rb +++ b/lib/feed2imap/maildir.rb @@ -19,7 +19,7 @@ along with this program. If not, see . require 'uri' require 'fileutils' require 'fcntl' -require 'rmail' +require 'mail' require 'socket' class MaildirAccount @@ -69,10 +69,8 @@ class MaildirAccount next if (not flags.index('S') or flags.index('F') or mtime > recent_time) - mail = File.open(fn) do |f| - RMail::Parser.read(f) - end - subject = mail.header['Subject'] + mail = Mail.read(fn) + subject = mail.subject if dryrun puts "To remove: #{subject} #{mtime}" else @@ -142,10 +140,13 @@ class MaildirAccount subdir = File.join(dir, d) raise "#{subdir} not a directory" unless File.directory? subdir Dir[File.join(subdir, '*')].each do |fn| - File.open(fn) do |f| - mail = RMail::Parser.read(f) - cache_index = mail.header['Message-ID'] - if cache_index && (cache_index == idx || cache_index == "<#{idx}>") + mail = Mail.read(fn) + cache_index = mail.message_id + if cache_index + if idx.start_with? '<' and idx.end_with? '>' + cache_index = "<#{cache_index}>" + end + if cache_index == idx dir_paths.push(File.join(d, File.basename(fn))) end end -- cgit v1.2.3-54-g00ecf