]> git.cworth.org Git - sup/commitdiff
fixed inifinite loop when polling drafts if there are no drafts
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 25 Dec 2006 21:42:29 +0000 (21:42 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 25 Dec 2006 21:42:29 +0000 (21:42 +0000)
(whoops!)

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@94 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/draft.rb

index d53963a375df2704219b734da03baa322137e1ed..b1425eb1e721449e214fa64907e957de7e15597b 100644 (file)
@@ -49,13 +49,8 @@ class DraftLoader < Source
   def id; DraftManager.source_id; end
   def to_s; DraftManager.source_name; end
 
-  def next
-    ret = nil
-    begin
-      ret = cur_offset
-      self.cur_offset = cur_offset + 1
-    end until File.exists? fn_for_offset(ret)
-    [ret, [:draft]]
+  def each
+    Dir.entries(@dir).select { |x| x =~ /^\d+$/ }.sort_by { |x| x.to_i }.each { |id| yield [id, [:draft]] }
   end
 
   def gen_offset