]> code.delx.au - offlineimap/commitdiff
All changes fixed, I think
authorJohn Goerzen <jgoerzen@complete.org>
Thu, 29 May 2008 05:28:13 +0000 (00:28 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Thu, 29 May 2008 05:28:13 +0000 (00:28 -0500)
src/Data/Syncable.hs
testsrc/runtests.hs

index 269cf90475d72a63adbe90028f9175303bc0d5e3..62e2ee481c866af9b1b81edd07630d15665d537f 100644 (file)
@@ -180,5 +180,5 @@ unaryApplyChanges collection commands =
         makeChange collection (CopyItem key val) =
             Map.insert key val collection
         makeChange collection (ModifyContent key val) =
         makeChange collection (CopyItem key val) =
             Map.insert key val collection
         makeChange collection (ModifyContent key val) =
-            Map.insert key val collection
+            Map.adjust (\_ -> val) key collection
     in foldl makeChange collection commands
     in foldl makeChange collection commands
index 0456dd6f8c7f1c6a4c26dd1f412f949a69d55cbf..9252912d58b35b6b28a5db4f54dc9101dc07023c 100644 (file)
@@ -104,7 +104,33 @@ prop_allChangesToMaster master child =
 prop_allChanges :: SyncCollection Int Float -> SyncCollection Int Float -> SyncCollection Int Float -> Result
 prop_allChanges master child lastchild =
     let (resMaster, resChild) = syncBiDir master child lastchild
 prop_allChanges :: SyncCollection Int Float -> SyncCollection Int Float -> SyncCollection Int Float -> Result
 prop_allChanges master child lastchild =
     let (resMaster, resChild) = syncBiDir master child lastchild
-        masterChildCommon = findModified child master
+        masterChildCommon = 
+            Map.fromList . catMaybes . map procKV . Map.toList . Map.union
+                (Map.intersection master lastchild) $
+                (Map.intersection child master)
+            where procKV (k, v) =
+                      case (Map.lookup k master, Map.lookup k child,
+                            Map.lookup k lastchild) of
+                        (Just m, Just c, Just lc) ->
+                            if lc == c 
+                               then if lc == m
+                                    then Nothing
+                                    else Just (k, m)
+                               else Just (k, c)
+                        (Just m, Just c, Nothing) -> 
+                            if m == c
+                               then Nothing
+                               else Just (k, c)
+                        (Just m, Nothing, Just lc) ->
+                            if m == lc
+                               then Nothing
+                               else Just (k, m)
+                        (Nothing, Just c, Just lc) ->
+                            if c == lc
+                               then Nothing
+                               else Just (k, c)
+                        _ -> Nothing
+                               
         masterMods = findNewMods masterChildCommon master
         childMods = findNewMods masterChildCommon child
 
         masterMods = findNewMods masterChildCommon master
         childMods = findNewMods masterChildCommon child