summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAntonio Terceiro <terceiro@debian.org>2013-08-13 01:01:59 +0200
committerAntonio Terceiro <terceiro@softwarelivre.org>2013-08-13 01:51:52 +0200
commit893eda640f3344adc08d77b475297a1353691d38 (patch)
treefbe706dcf7fdf4edef7d349e49f2aad95a7f568c /lib
parentb55bf0a982752bf594dd25fb88b07222e45899a5 (diff)
downloadfeed2imap-893eda640f3344adc08d77b475297a1353691d38.tar.gz
feed2imap-893eda640f3344adc08d77b475297a1353691d38.tar.bz2
feed2imap-893eda640f3344adc08d77b475297a1353691d38.zip
Fix MaildirAccount class; add tests
Diffstat (limited to '')
-rw-r--r--lib/feed2imap/maildir.rb24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/feed2imap/maildir.rb b/lib/feed2imap/maildir.rb
index eb7c8a2..8a5ade1 100644
--- a/lib/feed2imap/maildir.rb
+++ b/lib/feed2imap/maildir.rb
@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
require 'uri'
require 'fileutils'
require 'fcntl'
+require 'rmail'
+require 'socket'
class MaildirAccount
MYHOSTNAME = Socket.gethostname
@@ -67,9 +69,10 @@ class MaildirAccount
next if (not flags.index('S') or
flags.index('F') or
mtime > recent_time)
- File.open(fn) do |f|
- mail = RMail::Parser.read(f)
+ mail = File.open(fn) do |f|
+ RMail::Parser.read(f)
end
+ subject = mail.header['Subject']
if dryrun
puts "To remove: #{subject} #{mtime}"
else
@@ -141,9 +144,10 @@ class MaildirAccount
Dir[File.join(subdir, '*')].each do |fn|
File.open(fn) do |f|
mail = RMail::Parser.read(f)
- cache_index = mail.header['Message-Id']
- next if not (cache_index and cache_index == idx)
- dir_paths.push(File.join(d, File.basename(fn)))
+ cache_index = mail.header['Message-ID']
+ if cache_index && (cache_index == idx || cache_index == "<#{idx}>")
+ dir_paths.push(File.join(d, File.basename(fn)))
+ end
end
end
end
@@ -171,5 +175,15 @@ class MaildirAccount
@@seq_num += 1
fn
end
+
+ def maildir_file_info_flags(fn)
+ parts = fn.split(',')
+ if parts.size == 1
+ ''
+ else
+ parts.last
+ end
+ end
+
end