bin/sup-sync in sup-0.9.1 vs bin/sup-sync in sup-0.10
- old
+ new
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
require 'uri'
require 'rubygems'
require 'trollop'
-require "sup"
+require "sup"; Redwood::check_library_version_against "0.10"
PROGRESS_UPDATE_INTERVAL = 15 # seconds
class Float
def to_s; sprintf '%.2f', self; end
@@ -74,10 +74,11 @@
text <<EOS
Other options:
EOS
+ opt :index, "Use this index type ('auto' for autodetect)", :default => "auto"
opt :verbose, "Print message ids as they're processed."
opt :optimize, "As the final operation, optimize the index."
opt :all_sources, "Scan over all sources.", :short => :none
opt :dry_run, "Don't actually modify the index. Probably only useful with --verbose.", :short => "-n"
opt :version, "Show version information", :short => :none
@@ -93,11 +94,11 @@
target = [:new, :changed, :all, :restored].find { |x| opts[x] } || :new
op = [:asis, :restore, :discard].find { |x| opts[x] } || :asis
Redwood::start
-index = Redwood::Index.init
+index = Redwood::Index.init opts[:index]
restored_state = if opts[:restore]
dump = {}
puts "Loading state dump from #{opts[:restore]}..."
IO.foreach opts[:restore] do |l|
@@ -224,10 +225,10 @@
if Time.now - last_info_time > PROGRESS_UPDATE_INTERVAL
last_info_time = Time.now
elapsed = last_info_time - start_time
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)
- printf "## read %dm (about %.0f%%) @ %.1fm/s. %s elapsed, about %s remaining\n", num_scanned, pctdone, num_scanned / elapsed, elapsed.to_time_s, remaining.to_time_s
+ printf "## read %dm (~%.0f%%) @ %.1fm/s. %s elapsed, ~%s remaining, offset #{source.cur_offset}\n", num_scanned, pctdone, num_scanned / elapsed, elapsed.to_time_s, remaining.to_time_s
end
end
puts "Scanned #{num_scanned}, added #{num_added}, updated #{num_updated} messages from #{source}."
puts "Restored state on #{num_restored} (#{100.0 * num_restored / num_scanned}%) messages." if num_restored > 0