sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 2386b9f8a568cd23e9389ced7fbb1a1a01c153d8
parent 35802a64887e4c5dbd4d92ff908f3f082e5ecfa7
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Fri, 11 May 2007 04:45:27 +0000

imap: binc workaround

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@394 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M lib/sup/imap.rb | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb
@@ -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