From cf5ae65cd446c1dea53c681798bf1590f9588df7 Mon Sep 17 00:00:00 2001 From: Rich Lane Date: Sat, 20 Jun 2009 13:50:00 -0700 Subject: [PATCH] remove load_entry_for_id call in sup-recover-sources --- bin/sup-recover-sources | 12 +++++------- lib/sup/index.rb | 6 ++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/sup-recover-sources b/bin/sup-recover-sources index d3b1424..6e3810c 100755 --- a/bin/sup-recover-sources +++ b/bin/sup-recover-sources @@ -69,15 +69,14 @@ ARGV.each do |fn| Redwood::MBox::Loader.new(fn, nil, !$opts[:unusual], $opts[:archive]) end - source_ids = {} + source_ids = Hash.new 0 count = 0 source.each do |offset, labels| m = Redwood::Message.new :source => source, :source_info => offset - docid, entry = index.load_entry_for_id m.id - next unless entry - #puts "# #{source} #{offset} #{entry[:source_id]}" - - source_ids[entry[:source_id]] = (source_ids[entry[:source_id]] || 0) + 1 + m.load_from_source! + source_id = index.source_for_id m.id + next unless source_id + source_ids[source_id] += 1 count += 1 break if count == $opts[:scan_num] end @@ -86,7 +85,6 @@ ARGV.each do |fn| id = source_ids.keys.first.to_i puts "assigned #{source} to #{source_ids.keys.first}" source.id = id - source.seek_to! source.total index.add_source source else puts ">> unable to determine #{source}: #{source_ids.inspect}" diff --git a/lib/sup/index.rb b/lib/sup/index.rb index a621ba1..09b41cf 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -494,6 +494,12 @@ EOS @index_mutex.synchronize { @index.optimize } end + def source_for_id id + entry = @index[id] + return unless entry + entry[:source_id].to_i + end + class ParseError < StandardError; end ## parse a query string from the user. returns a query object -- 2.45.2