]> git.cworth.org Git - sup/commitdiff
another bugfix when polling for new messages
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 5 Jan 2007 20:08:00 +0000 (20:08 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 5 Jan 2007 20:08:00 +0000 (20:08 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@189 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/imap.rb

index 764db46a808f4907ea65a705cf0ef1f4efe95124..5affec35345cb1ab2508f9a784d46c8ff21219df 100644 (file)
@@ -169,20 +169,21 @@ private
   end
 
   def scan_mailbox
+    Redwood::log "#{SCAN_INTERVAL - (Time.now - @last_scan)} seconds to go before resizing mailbox" if @last_scan
     return if @last_scan && (Time.now - @last_scan) < SCAN_INTERVAL
 
     @imap.examine mailbox
-    last_id = @imap.responses["EXISTS"][-1]
-    return if last_id == @ids.length + 1
+    last_id = @imap.responses["EXISTS"].last
+    @last_scan = Time.now
+    Redwood::log "IMAP server reports last id as #{last_id}. I have a last id of #{@ids.length}"
+    return if last_id == @ids.length
     Redwood::log "fetching IMAP headers #{(@ids.length + 1) .. last_id}"
-    File.open("asdf.txt", "w") { |f| f.puts "fetching IMAP headers #{(@ids.length + 1) .. last_id}" }
     values = @imap.fetch((@ids.length + 1) .. last_id, ['RFC822.SIZE', 'INTERNALDATE'])
     values.each do |v|
       id = make_id v
       @ids << id
       @imap_ids[id] = v.seqno
     end
-    @last_scan = Time.now
   end
 
   def die_from e, opts={}