]> git.cworth.org Git - sup/commitdiff
bugfix: make sup-sync work again under new index-writing scheme
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 29 Feb 2008 02:55:19 +0000 (18:55 -0800)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 29 Feb 2008 02:55:19 +0000 (18:55 -0800)
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.

bin/sup-sync
lib/sup/index.rb
lib/sup/poll.rb

index 4a05257f9b515374ee9235629a3a906a09b024cc..ac5caf6c6b724e2df48db24afb46994e8cfaa683 100644 (file)
@@ -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
 
index 2991fa387e8688f534dbfaf9cdd6a01a9e10e856..cea90dddcd346bf4912d7dcfc465e33620b64aef 100644 (file)
@@ -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,
index 2dd915011c26c8310a0290f5499c0f18b80e9d94..09f5de3898e57c2d683ae9756ac3700c9473ccb3 100644 (file)
@@ -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}"