]> code.delx.au - offlineimap/blobdiff - src/Data/Syncable.hs
diffCollection now works with values
[offlineimap] / src / Data / Syncable.hs
index 08cd82a10c5d19532a26ef22fd39f565ff803454..fcafda1e9d242c75435caaf6e8bead061ab3350e 100644 (file)
@@ -126,19 +126,21 @@ syncBiDir masterstate childstate lastchildstate =
           -- then subtract out any items in the master changes that have the
           -- same key.
           childPayloadChanges = 
-              foldl (\m (k, v) -> Map.adjust (\_ -> v) k m)
+              Map.difference
                         (findModified childstate masterstate lastchildstate)
-                        (Map.toList $ findModified masterstate childstate lastchildstate)
+                        (findModified masterstate childstate lastchildstate)
 
 {- | Compares two SyncCollections, and returns the commands that, when
 applied to the first collection, would yield the second. -}
-diffCollection :: (Ord k, Show k, Show v) => 
+diffCollection :: (Ord k, Show k, Eq v, Show v) => 
                   SyncCollection k v
                -> SyncCollection k v
                -> [SyncCommand k v]
 diffCollection coll1 coll2 = 
     (map DeleteItem . findDeleted coll2 coll1 $ coll1) ++
-    (map (pairToFunc CopyItem) . findAdded coll2 coll1 $ coll1)
+    (map (pairToFunc CopyItem) . findAdded coll2 coll1 $ coll1) ++
+    (map (pairToFunc ModifyContent) . Map.toList .
+         findModified coll1 coll2 $ coll1)
 
 {- | Returns a list of keys that exist in state2 and lastchildstate
 but not in state1 -}