]> git.cworth.org Git - sup/commitdiff
fixed broken draft autoloading on first draft
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 9 Feb 2007 07:40:42 +0000 (07:40 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 9 Feb 2007 07:40:42 +0000 (07:40 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@310 5c8cc53c-5e98-4d25-b20a-d8db53a31250

doc/TODO
lib/sup/draft.rb
lib/sup/modes/thread-index-mode.rb
lib/sup/poll.rb
lib/sup/source.rb

index 3233779464a8f6efeaec53affe55d00d8e3a9366..1fb135527d9b69449dfb295fda8882f885a6bd79 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -9,6 +9,7 @@ bugfix: changing IMAP ids
 de-archived messages should be auto-added to inbox
 maildir
 undo
+remove stupid percent_done source methods
 
 future
 ------
index 49ddf3f1cbbc9a785c3ae3f8e9c35182cc2417f8..ce292bef610b9ce17c875bc299f532d7e48c2dfe 100644 (file)
@@ -55,9 +55,9 @@ class DraftLoader < Source
   def uri; DraftManager.source_name; end
 
   def each
-    ids = Dir.entries(@dir).select { |x| x =~ /^\d+$/ }.map { |x| x.to_i }.sort
+    ids = get_ids
     ids.each do |id|
-      if id > cur_offset
+      if id >= cur_offset
         self.cur_offset = id
         yield [id, [:draft, :inbox]]
       end
@@ -107,7 +107,16 @@ class DraftLoader < Source
   end
 
   def start_offset; 0; end
-  def end_offset; Dir.new(@dir).entries.sort.last.to_i; end
+  def end_offset
+    ids = get_ids
+    ids.empty? ? 0 : (ids.last + 1)
+  end
+
+private
+
+  def get_ids
+    Dir.entries(@dir).select { |x| x =~ /^\d+$/ }.map { |x| x.to_i }.sort
+  end
 end
 
 Redwood::register_yaml(DraftLoader, %w(cur_offset))
index 70bbffd8cde784c102e83b7e96ec3b09d68d1ff9..9cceaa634f587e209a026d6a6ca62bab07c899fd 100644 (file)
@@ -57,6 +57,7 @@ class ThreadIndexMode < LineCursorMode
   def select t=nil
     t ||= @threads[curpos]
 
+    ## this isn't working entirely. TODO:figure out why
     t = t.clone # required so that messages added later on don't completely
                 # screw everything up
 
@@ -327,7 +328,7 @@ class ThreadIndexMode < LineCursorMode
   def load_n_threads n=LOAD_MORE_THREAD_NUM, opts={}
     @mbid = BufferManager.say "Searching for threads..."
     orig_size = @ts.size
-    last_update = Time.now
+    last_update = Time.now - 9999 # oh yeah
     @ts.load_n_threads(@ts.size + n, opts) do |i|
       BufferManager.say "Loaded #{i} threads...", @mbid
       if (Time.now - last_update) >= 0.25
index 009f26b4d6bd04f1dedf90d993ae201c631d8b06..cbad96c3f2a2f1804b3881966874473ee2f04125 100644 (file)
@@ -43,6 +43,7 @@ class PollManager
     @mutex.synchronize do
       found = {}
       Index.usual_sources.each do |source|
+#        yield "source #{source} is done? #{source.done?} (cur_offset #{source.cur_offset} >= #{source.end_offset})"
         yield "Loading from #{source}... " unless source.done? || source.broken?
         num = 0
         numi = 0
index 9571d6a12d822eff7693d3d02c2014792c2b8331..8aa3537f4e429afc2a8c0b579d2753ee23976078 100644 (file)
@@ -25,7 +25,7 @@ class Source
   ## To write a new source, subclass this class, and implement:
   ##
   ## - start_offset
-  ## - end_offset
+  ## - end_offset (exclusive!)
   ## - pct_done (percent of the way cur_offset is to end_offset)
   ## - load_header offset
   ## - load_message offset