sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 6339e161040978e13358753139c9e72023c454ee
parent 69312a6818e995d5319396fbf904bd6f1469d6a2
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Mon, 18 Jan 2010 22:54:42 -0800

handle multiple locations in sup-sync and poll

Diffstat:
M bin/sup-sync | 4 +++-
M lib/sup/poll.rb | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/bin/sup-sync b/bin/sup-sync
@@ -153,7 +153,7 @@ begin
         ## skip this message if we're operating only on changed messages, the
         ## message is in the index, and it's unchanged from what the source is
         ## reporting.
-        next if old_m && old_m.source.id == m.source.id && old_m.source_info == m.source_info
+        next if old_m && old_m.locations.member?([m.source, m.source_info])
       when :restored
         ## skip if we're operating on restored messages, and this one
         ## ain't (or we wouldn't be making a change)
@@ -204,6 +204,8 @@ begin
         end
       end
 
+      m.locations = old_m.locations + m.locations if old_m
+
       ## now, actually do the operation
       case dothis
       when :add_message
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
@@ -116,13 +116,14 @@ EOS
         each_message_from source do |m|
           old_m = Index.build_message m.id
           if old_m
-              if old_m.source.id != source.id || old_m.source_info != m.source_info
+            if not old_m.locations.member? [source, m.source_info]
               ## here we merge labels between new and old versions, but we don't let the new
               ## message add :unread or :inbox labels. (they can exist in the old version,
               ## just not be added.)
               new_labels = old_m.labels + (m.labels - [:unread, :inbox])
               yield "Message at #{m.source_info} is an updated of an old message. Updating labels from #{m.labels.to_a * ','} => #{new_labels.to_a * ','}"
               m.labels = new_labels
+              m.locations = old_m.locations + m.locations
               Index.update_message m
             else
               yield "Skipping already-imported message at #{m.source_info}"