From: wmorgan Date: Thu, 4 Jan 2007 06:17:11 +0000 (+0000) Subject: fixed percent_done thing X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=da90f10fddd262ce86bf8318a76d4c8ffdc8f54b;p=sup fixed percent_done thing git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@172 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/bin/sup-import b/bin/sup-import index da34483..c7e5272 100644 --- a/bin/sup-import +++ b/bin/sup-import @@ -49,6 +49,7 @@ the following options: --force-read: any messages found will not be marked as new. The following options can also be specified: + --verbose: print message ids as they're processed --the-usual: import new messages from all usual sources --rebuild: rebuild the index for the specified sources rather than just adding new messages. Useful if the sources @@ -62,6 +63,7 @@ The following options can also be specified: EOS exit end +#' stupid ruby-mode ## for sources that require login information, prompt the user for ## that. also provide a list of previously-defined login info to @@ -105,6 +107,7 @@ the_usual = ARGV.delete "--the-usual" rebuild = ARGV.delete "--rebuild" force_rebuild = ARGV.delete "--force-rebuild" optimize = ARGV.delete "--optimize" +verbose = ARGV.delete "--verbose" start_at = # ok really need to use optparse or something now if(i = ARGV.index("--start-at")) raise "start-at requires a numeric argument: #{ARGV[i + 1].inspect}" unless ARGV.length > (i + 1) && ARGV[i + 1] =~ /\d/ @@ -179,7 +182,7 @@ begin end m.remove_label :unread if m.source_marked_read? unless force_read - puts "# message at #{offset}, labels: #{labels * ', '}" unless rebuild + puts "# message at #{offset}, labels: #{labels * ', '}" if verbose unless rebuild if (rebuild || force_rebuild) && (docid, entry = index.load_entry_for_id(m.id)) && entry if force_rebuild || entry[:source_info].to_i != offset diff --git a/lib/sup/imap.rb b/lib/sup/imap.rb index 5aeac17..3136e0a 100644 --- a/lib/sup/imap.rb +++ b/lib/sup/imap.rb @@ -204,6 +204,8 @@ class IMAP < Source @mutex.synchronize { connect or raise SourceError, broken_msg } @ids.last end + + def pct_done; 100.0 * (@ids.index(cur_offset) || 0).to_f / (@ids.length - 1).to_f; end end Redwood::register_yaml(IMAP, %w(uri username password cur_offset usual archived id)) diff --git a/lib/sup/mbox/loader.rb b/lib/sup/mbox/loader.rb index 4013d4d..68438ec 100644 --- a/lib/sup/mbox/loader.rb +++ b/lib/sup/mbox/loader.rb @@ -29,7 +29,7 @@ class Loader < Source def start_offset; 0; end def end_offset; File.size @f; end - def total; end_offset; end + def pct_done; 100.0 * cur_offset.to_f / end_offset.to_f; end def load_header offset header = nil