From: wmorgan Date: Sun, 11 Feb 2007 21:04:48 +0000 (+0000) Subject: made pct_done optional X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=17b8b9e9641017fad55ba687eb4e58404d2cb00c;p=sup made pct_done optional git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@320 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/bin/sup-import b/bin/sup-import index 55b5049..0d859e5 100644 --- a/bin/sup-import +++ b/bin/sup-import @@ -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 diff --git a/doc/TODO b/doc/TODO index b490075..1ca11fb 100644 --- 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 diff --git a/lib/sup/mbox/loader.rb b/lib/sup/mbox/loader.rb index f2c0407..2f69dbf 100644 --- a/lib/sup/mbox/loader.rb +++ b/lib/sup/mbox/loader.rb @@ -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 diff --git a/lib/sup/source.rb b/lib/sup/source.rb index 8aa3537..d3f96e1 100644 --- a/lib/sup/source.rb +++ b/lib/sup/source.rb @@ -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