From: wmorgan Date: Fri, 11 May 2007 04:45:27 +0000 (+0000) Subject: imap: binc workaround X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=2386b9f8a568cd23e9389ced7fbb1a1a01c153d8;p=sup imap: binc workaround git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@394 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb index 6978120..e9b83ef 100644 --- 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