]> git.cworth.org Git - sup/commitdiff
made pct_done optional
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sun, 11 Feb 2007 21:04:48 +0000 (21:04 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sun, 11 Feb 2007 21:04:48 +0000 (21:04 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@320 5c8cc53c-5e98-4d25-b20a-d8db53a31250

bin/sup-import
doc/TODO
lib/sup/mbox/loader.rb
lib/sup/source.rb

index 55b5049ca47ad07cb5f817046a9f3d45bd84759a..0d859e56ae6dc77808eacef98dca4fad5d545632 100644 (file)
@@ -76,7 +76,7 @@ if opts[:rebuild] || opts[:full_rebuild]
   end
 end
 
-start = Time.now
+last_update = start = Time.now
 found = {}
 begin
   sources.each do |source|
@@ -93,10 +93,10 @@ begin
         m.labels -= [:unread] if opts[:read]
       end
 
-      num = num_added + num_updated
-      if num % 1000 == 0 && num > 0
-        elapsed = Time.now - start
-        pctdone = source.pct_done
+      if Time.now - last_update > 60
+        last_update = Time.now
+        elapsed = last_update - start
+        pctdone = source.respond_to?(:pct_done) ? source.pct_done : 100.0 * (source.cur_offset.to_f - source.start_offset).to_f / (source.end_offset - source.start_offset).to_f
         remaining = (100.0 - pctdone) * (elapsed.to_f / pctdone)
         puts "## #{num} (#{pctdone}% done) read; #{elapsed.to_time_s} elapsed; est. #{remaining.to_time_s} remaining"
       end
index b490075e78c827bbee520c6ee6aab30c201db8a8..1ca11fb2c0544988ea6e05e8d2eb65c5b91ac8d6 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,16 +1,14 @@
 for next release
 ----------------
-don't quit while writing thread index state to disk or with unsaved drafts/messages
 make 'a' archive in thread-view-mode
 message attachments
 warnings: top-posting, attachments
-de-archived messages should be auto-added to inbox
 maildir
 undo
-remove stupid percent_done source methods
 
 future
 ------
+maybe: de-archived messages should be auto-added to inbox
 swappable keymappings
 bugfix: when returning from a shelling out, ncurses is crazy 
 bugfix: miscellaneous weirdnesses in buffer line editing
@@ -34,6 +32,8 @@ toggle wrapping
 
 done
 ----
+x remove stupid percent_done source methods (still useful; made it optional)
+x don't quit while writing thread index state to disk or with unsaved drafts/messages
 x bugfix: deleted threads are showing up (i don't see this any more)
 x bugfix: changing IMAP ids
 x bugfix: STILL new messages, drafts sometimes not showing up in inbox
index f2c0407b2e16ec108a3704f1465d55b78e033325..2f69dbf690c9a34b2bbbd0e3979cb3881699ce34 100644 (file)
@@ -29,7 +29,6 @@ class Loader < Source
 
   def start_offset; 0; end
   def end_offset; File.size @f; end
-  def pct_done; 100.0 * cur_offset.to_f / end_offset.to_f; end
 
   def load_header offset
     header = nil
index 8aa3537f4e429afc2a8c0b579d2753ee23976078..d3f96e179126a2a1e6f988bee5492e0b1e0dfe63 100644 (file)
@@ -26,7 +26,6 @@ class Source
   ##
   ## - start_offset
   ## - end_offset (exclusive!)
-  ## - pct_done (percent of the way cur_offset is to end_offset)
   ## - load_header offset
   ## - load_message offset
   ## - raw_header offset