commit 78cd02adf84948768a70d6627d8c5302e09b8eac
parent ab2f27a958c904d87f11d494a4034c6edfb9e3d0
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Fri, 5 Jan 2007 20:08:00 +0000
another bugfix when polling for new messages
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@189 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git 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={}