commit 3e95c6799666b0e9cd1b202370acd0109923b256
parent dcd480edbf6f50a0c86298fd61ee8d517da53d0c
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Mon, 17 Sep 2007 17:08:40 +0000
i think this should fix the problem of empty maildirs and imap folders causing sup to crash (whoops)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@583 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb
@@ -87,6 +87,8 @@ class IMAP < Source
def ssl?; @parsed_uri.scheme == 'imaps' end
def check
+ return unless start_offset
+
ids =
@mutex.synchronize do
unsynchronized_scan_mailbox
@@ -149,6 +151,8 @@ class IMAP < Source
synchronized :scan_mailbox
def each
+ return unless start_offset
+
ids =
@mutex.synchronize do
unsynchronized_scan_mailbox
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
@@ -35,6 +35,8 @@ class Maildir < Source
def check
scan_mailbox
+ return unless start_offset
+
start = @ids.index(cur_offset || start_offset) or raise OutOfSyncSourceError, "Unknown message id #{cur_offset || start_offset}." # couldn't find the most recent email
end
@@ -92,6 +94,8 @@ class Maildir < Source
def each
scan_mailbox
+ return unless start_offset
+
start = @ids.index(cur_offset || start_offset) or raise OutOfSyncSourceError, "Unknown message id #{cur_offset || start_offset}." # couldn't find the most recent email
start.upto(@ids.length - 1) do |i|
diff --git a/lib/sup/source.rb b/lib/sup/source.rb
@@ -77,7 +77,7 @@ class Source
def seek_to! o; self.cur_offset = o; end
def reset!; seek_to! start_offset; end
def == o; o.uri == uri; end
- def done?; (self.cur_offset ||= start_offset) >= end_offset; end
+ def done?; start_offset.nil? || (self.cur_offset ||= start_offset) >= end_offset; end
def is_source_for? uri; uri == URI(uri); end
## check should throw a FatalSourceError or an OutOfSyncSourcError