]> git.notmuchmail.org Git - sup/commitdiff
imap: binc workaround
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 11 May 2007 04:45:27 +0000 (04:45 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 11 May 2007 04:45:27 +0000 (04:45 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@394 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/imap.rb

index 6978120c5500974a48a5dc26ce92a635df55bd0d..e9b83ef849521731a75db9d68a6e41576d9e8ace 100644 (file)
@@ -115,9 +115,16 @@ class IMAP < Source
 
     return if last_id == @ids.length
 
-    Redwood::log "fetching IMAP headers #{(@ids.length + 1) .. last_id}"
-    values = safely { @imap.fetch((@ids.length + 1) .. last_id, ['RFC822.SIZE', 'INTERNALDATE']) }
-    values.each do |v|
+    range = (@ids.length + 1) .. last_id
+    Redwood::log "fetching IMAP headers #{range}"
+    values = safely { @imap.fetch range, ['RFC822.SIZE', 'INTERNALDATE'] }
+    relevant_values = values.find_all { |v| range.include? v.seqno }
+
+    if relevant_values.size < values.size
+      Redwood::log "You IMAP server is buggy: it returned #{values.size} headers for a request for #{range.size}. What are you using, Binc?"
+    end
+
+    relevant_values.each do |v|
       id = make_id v
       @ids << id
       @imap_ids[id] = v.seqno