Allow merging in of labels from duplicate messages, EXCEPT for
:unread and :inbox labels. (These two have special semantics
and, in contrast to the other special-semantics labels, might
appear on a new message.)
## assign message labels based on the operation we're performing
case op
when :asis
- m.labels = (m.labels + index_state).uniq if index_state
+ m.labels = ((m.labels - [:unread, :inbox]) + index_state).uniq if index_state
when :restore
## if the entry exists on disk
if restored_state[m.id]
numi = 0
add_messages_from source do |m, offset, entry|
## always preserve the labels on disk.
- m.labels = (m.labels + entry[:label].split(/\s+/).map { |x| x.intern }).uniq if entry
+ m.labels = ((m.labels - [:unread, :inbox]) + entry[:label].split(/\s+/).map { |x| x.intern }).uniq if entry
yield "Found message at #{offset} with labels {#{m.labels * ', '}}"
unless entry
num += 1