]> git.cworth.org Git - sup/commitdiff
i think this should fix the problem of empty maildirs and imap folders causing sup...
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 17 Sep 2007 17:08:40 +0000 (17:08 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 17 Sep 2007 17:08:40 +0000 (17:08 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@583 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/imap.rb
lib/sup/maildir.rb
lib/sup/source.rb

index c1ba2bf6c4b366d1d60c1d79bcf22d6a5d81163d..24b4e6e0bda426b57ba4e79681541a288d79af4f 100644 (file)
@@ -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
index 2ecfbe7d67383f24af53c6c1c0689fa9e554f7e1..c754ccdf49aca1b1c1504a4b056f565b278b96b2 100644 (file)
@@ -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|         
index db91d11f664cbdc585cb481f8d98a3117401662c..d21faf70eb5452ca33f9d1177d436df00a1886e4 100644 (file)
@@ -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