commit 1c7df13ae28a079b7d74b0c826f1a8fa906e8035
parent a842c631a27eba1e6b1aa3a4eefdefb1670bae2c
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Thu, 28 Feb 2008 18:55:19 -0800
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.
Diffstat:
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git 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
@@ -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
@@ -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}"