]> git.cworth.org Git - sup/blobdiff - bin/sup-sync
rejigger sup-sync logic slightly
[sup] / bin / sup-sync
index b743c1c13e3cdf9f73d6d24a5c88882985c30681..ddcf8c567563574be9ecd3a1b84abf1daf51e024 100755 (executable)
@@ -112,7 +112,7 @@ else
 end
 
 seen = {}
-index.lock_or_die
+index.lock_interactively or exit
 begin
   index.load
 
@@ -173,13 +173,22 @@ begin
 
       ## decide what to do based on message labels and the operation we're performing
       dothis, new_labels = case
-      when (op == :restore) && restored_state[m.id] && old_m && (old_m.labels != restored_state[m.id])
-        [:update_message_state, restored_state[m.id]]
+      when (op == :restore) && restored_state[m.id]
+        if old_m && (old_m.labels != restored_state[m.id])
+          num_restored += 1
+          [:update_message_state, restored_state[m.id]]
+        elsif old_m.nil?
+          num_restored += 1
+          m.labels = restored_state[m.id]
+          :add_message
+        else
+          # labels are the same; don't do anything
+        end
       when op == :discard
         if old_m && (old_m.labels != m.labels)
           [:update_message_state, m.labels]
         else
-          # don't do anything
+          # labels are the same; don't do anything
         end
       else
         ## duplicate behavior of poll mode: if index_state is non-nil, this is a newer