From 6a1d8476735dd8c9581380cf6af8125da69022c4 Mon Sep 17 00:00:00 2001 From: lnu Date: Sat, 14 May 2005 08:51:02 +0000 Subject: cleaner way to manage dup ID git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@27 f70e237a-67f3-0310-a06c-d2b8a7116972 --- lib/feed2imap/imap.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/feed2imap/imap.rb') diff --git a/lib/feed2imap/imap.rb b/lib/feed2imap/imap.rb index 301b95c..db5df7a 100644 --- a/lib/feed2imap/imap.rb +++ b/lib/feed2imap/imap.rb @@ -100,12 +100,11 @@ class ImapAccount @connection.select(folder) searchres = @connection.search(['HEADER', 'X-CacheIndex', "-#{idx}-"]) flags = nil - if searchres.length == 1 + if searchres.length > 0 + # we get the flags from the first result and delete everything flags = @connection.fetch(searchres[0], 'FLAGS')[0].attr['FLAGS'] - @connection.store(searchres[0], "+FLAGS", [:Deleted]) + searchres.each { |m| @connection.store(m, "+FLAGS" [:Deleted]) } @connection.expunge - elsif searchres.length != 0 - raise "Search returned multiple results !!" end @connection.append(folder, mail, flags) end -- cgit v1.2.3-70-g09d2