From 78cd02adf84948768a70d6627d8c5302e09b8eac Mon Sep 17 00:00:00 2001 From: wmorgan Date: Fri, 5 Jan 2007 20:08:00 +0000 Subject: [PATCH] another bugfix when polling for new messages git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@189 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- lib/sup/imap.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb index 764db46..5affec3 100644 --- a/lib/sup/imap.rb +++ b/lib/sup/imap.rb @@ -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={} -- 2.45.2