diff options
Diffstat (limited to '')
-rw-r--r-- | lib/feed2imap/imap.rb | 7 |
1 files changed, 3 insertions, 4 deletions
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 |