Fixed to polling and differencing
authorPanagiotis Kanavos <pkanavos@gmail.com>
Thu, 23 Feb 2012 14:17:50 +0000 (16:17 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Thu, 23 Feb 2012 14:17:50 +0000 (16:17 +0200)
trunk/Pithos.Core/Agents/CollectionExtensions.cs
trunk/Pithos.Core/Agents/PollAgent.cs
trunk/Pithos.Core/Agents/SnapshotDifferencer.cs
trunk/Pithos.Network/NoModificationInfo.cs

index 5743c70..642d5bc 100644 (file)
@@ -55,12 +55,12 @@ namespace Pithos.Core.Agents
     /// </summary>\r
     public static class CollectionExtensions\r
     {\r
-        public static IEnumerable<T> Replace<T>(this IEnumerable<T> list,Func<T,bool> match, Func<T,IEnumerable<T>> replace)\r
+        public static IEnumerable<T> Replace<T>(this IEnumerable<T> list,Func<T,bool> match, Func<T,IEnumerable<T>> generate)\r
         {\r
             foreach (var item in list)\r
             {\r
                 if (match(item))\r
-                    foreach (var newItem in replace(item))\r
+                    foreach (var newItem in generate(item))\r
                     {\r
                         yield return newItem;\r
                     }\r
index 4071959..33a93be 100644 (file)
@@ -255,7 +255,7 @@ namespace Pithos.Core.Agents
 */\r
 \r
                         var cleanRemotes = (from info in remoteObjects.Union(sharedObjects)\r
-                                            let name = info.Name\r
+                                            let name = info.Name??""\r
                                             where !name.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase) &&\r
                                                   !name.StartsWith(FolderConstants.CacheFolder + "/",\r
                                                                    StringComparison.InvariantCultureIgnoreCase)\r
index 018553a..5c583ad 100644 (file)
@@ -81,17 +81,20 @@ namespace Pithos.Core.Agents
                 return this;\r
             }\r
 \r
+\r
+            //The previous values that correspond to a NoModification object\r
+            //have the same account, container and possibly the same folder\r
+            Func<ObjectInfo, ObjectInfo, bool> correspondsTo = (info, noMod) => \r
+                info.Account == noMod.Account\r
+                && info.Container == noMod.Container\r
+                && (noMod.Name == null || info.Name.StartsWith(noMod.Name));\r
+\r
             //Replace any NoModification entries with previous values that have\r
             //the same account, container and possibly, folder\r
             _current=list.Replace(\r
                 info => info is NoModificationInfo, \r
-                noMod => from info in _previous\r
-                        where \r
-                            info.Account==noMod.Account \r
-                            && info.Container==noMod.Container \r
-                            //If the NoModification specifies a folder, use it to match items below this folder\r
-                            && (noMod.Name==null || info.Name.StartsWith(noMod.Name))\r
-                        select info);\r
+                noMod => _previous.Where(info => correspondsTo(info, noMod)))\r
+                .ToList();\r
 \r
             return this;\r
         }\r
index a270947..bc0edc0 100644 (file)
@@ -33,5 +33,6 @@ namespace Pithos.Network
         {\r
             Name = folder + '/';\r
         }\r
+\r
     }\r
 }\r