From: William Morgan Date: Fri, 29 Feb 2008 02:55:19 +0000 (-0800) Subject: bugfix: make sup-sync work again under new index-writing scheme X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=1c7df13ae28a079b7d74b0c826f1a8fa906e8035;p=sup bugfix: make sup-sync work again under new index-writing scheme Index#sync_message and PollManager#add_messages_from now take an :force_overwrite option, which is used by sup-sync to override the new conservative "document copy" semantics of index updates so that index updates actually happen. --- diff --git a/bin/sup-sync b/bin/sup-sync index 4a05257..ac5caf6 100644 --- a/bin/sup-sync +++ b/bin/sup-sync @@ -133,7 +133,7 @@ begin num_added = num_updated = num_scanned = num_restored = 0 last_info_time = start_time = Time.now - Redwood::PollManager.add_messages_from source do |m, offset, entry| + Redwood::PollManager.add_messages_from source, :force_overwrite => true do |m, offset, entry| num_scanned += 1 seen[m.id] = true diff --git a/lib/sup/index.rb b/lib/sup/index.rb index 2991fa3..cea90dd 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -161,7 +161,7 @@ EOS ## and adding either way. Index state will be determined by m.labels. ## ## docid and entry can be specified if they're already known. - def sync_message m, docid=nil, entry=nil + def sync_message m, docid=nil, entry=nil, opts={} docid, entry = load_entry_for_id m.id unless docid && entry raise "no source info for message #{m.id}" unless m.source && m.source_info @@ -211,6 +211,10 @@ EOS entry = {} end + ## if force_overwite is true, ignore what's in the index. this is used + ## primarily by sup-sync to force index updates. + entry = {} if opts[:force_overwrite] + d = { :message_id => m.id, :source_id => source_id, diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb index 2dd9150..09f5de3 100644 --- a/lib/sup/poll.rb +++ b/lib/sup/poll.rb @@ -134,7 +134,7 @@ EOS ## labels. it is likely that callers will want to replace these with ## the index labels, if they exist, so that state is not lost when ## e.g. a new version of a message from a mailing list comes in. - def add_messages_from source + def add_messages_from source, opts={} begin return if source.done? || source.has_errors? @@ -157,7 +157,7 @@ EOS docid, entry = Index.load_entry_for_id m.id HookManager.run "before-add-message", :message => m m = yield(m, offset, entry) or next - Index.sync_message m, docid, entry + Index.sync_message m, docid, entry, opts UpdateManager.relay self, :added, m unless entry rescue MessageFormatError => e Redwood::log "ignoring erroneous message at #{source}##{offset}: #{e.message}"