commit cfcc9614576658b2892512a4e54c310d86cb299e
parent 7cf401d88e72af8f49f4cce8ba323214ce5542b2
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Mon, 16 Mar 2009 08:51:25 -0400
Merge branch 'merge-labels' into next
Diffstat:
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/bin/sup-sync b/bin/sup-sync
@@ -143,12 +143,7 @@ begin
next if target == :changed && entry && entry[:source_id].to_i == source.id && entry[:source_info].to_i == offset
## get the state currently in the index
- index_state =
- if entry
- entry[:label].split(/\s+/).map { |x| x.intern }
- else
- nil
- end
+ index_state = entry[:label].split(/\s+/).map { |x| x.intern } if entry
## skip if we're operating on restored messages, and this one
## ain't.
@@ -163,7 +158,7 @@ begin
## assign message labels based on the operation we're performing
case op
when :asis
- m.labels = index_state if index_state
+ m.labels = (m.labels + index_state).uniq if index_state
when :restore
## if the entry exists on disk
if restored_state[m.id]
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
@@ -97,7 +97,7 @@ EOS
numi = 0
add_messages_from source do |m, offset, entry|
## always preserve the labels on disk.
- m.labels = entry[:label].split(/\s+/).map { |x| x.intern } if entry
+ m.labels = (m.labels + entry[:label].split(/\s+/).map { |x| x.intern }).uniq if entry
yield "Found message at #{offset} with labels {#{m.labels * ', '}}"
unless entry
num += 1