From 92f18b561f924c2d6beab14a2d31179dfa847295 Mon Sep 17 00:00:00 2001 From: Panagiotis Kanavos Date: Thu, 23 Feb 2012 16:17:50 +0200 Subject: [PATCH] Fixed to polling and differencing --- trunk/Pithos.Core/Agents/CollectionExtensions.cs | 4 ++-- trunk/Pithos.Core/Agents/PollAgent.cs | 2 +- trunk/Pithos.Core/Agents/SnapshotDifferencer.cs | 17 ++++++++++------- trunk/Pithos.Network/NoModificationInfo.cs | 1 + 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/trunk/Pithos.Core/Agents/CollectionExtensions.cs b/trunk/Pithos.Core/Agents/CollectionExtensions.cs index 5743c70..642d5bc 100644 --- a/trunk/Pithos.Core/Agents/CollectionExtensions.cs +++ b/trunk/Pithos.Core/Agents/CollectionExtensions.cs @@ -55,12 +55,12 @@ namespace Pithos.Core.Agents /// public static class CollectionExtensions { - public static IEnumerable Replace(this IEnumerable list,Func match, Func> replace) + public static IEnumerable Replace(this IEnumerable list,Func match, Func> generate) { foreach (var item in list) { if (match(item)) - foreach (var newItem in replace(item)) + foreach (var newItem in generate(item)) { yield return newItem; } diff --git a/trunk/Pithos.Core/Agents/PollAgent.cs b/trunk/Pithos.Core/Agents/PollAgent.cs index 4071959..33a93be 100644 --- a/trunk/Pithos.Core/Agents/PollAgent.cs +++ b/trunk/Pithos.Core/Agents/PollAgent.cs @@ -255,7 +255,7 @@ namespace Pithos.Core.Agents */ var cleanRemotes = (from info in remoteObjects.Union(sharedObjects) - let name = info.Name + let name = info.Name??"" where !name.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase) && !name.StartsWith(FolderConstants.CacheFolder + "/", StringComparison.InvariantCultureIgnoreCase) diff --git a/trunk/Pithos.Core/Agents/SnapshotDifferencer.cs b/trunk/Pithos.Core/Agents/SnapshotDifferencer.cs index 018553a..5c583ad 100644 --- a/trunk/Pithos.Core/Agents/SnapshotDifferencer.cs +++ b/trunk/Pithos.Core/Agents/SnapshotDifferencer.cs @@ -81,17 +81,20 @@ namespace Pithos.Core.Agents return this; } + + //The previous values that correspond to a NoModification object + //have the same account, container and possibly the same folder + Func correspondsTo = (info, noMod) => + info.Account == noMod.Account + && info.Container == noMod.Container + && (noMod.Name == null || info.Name.StartsWith(noMod.Name)); + //Replace any NoModification entries with previous values that have //the same account, container and possibly, folder _current=list.Replace( info => info is NoModificationInfo, - noMod => from info in _previous - where - info.Account==noMod.Account - && info.Container==noMod.Container - //If the NoModification specifies a folder, use it to match items below this folder - && (noMod.Name==null || info.Name.StartsWith(noMod.Name)) - select info); + noMod => _previous.Where(info => correspondsTo(info, noMod))) + .ToList(); return this; } diff --git a/trunk/Pithos.Network/NoModificationInfo.cs b/trunk/Pithos.Network/NoModificationInfo.cs index a270947..bc0edc0 100644 --- a/trunk/Pithos.Network/NoModificationInfo.cs +++ b/trunk/Pithos.Network/NoModificationInfo.cs @@ -33,5 +33,6 @@ namespace Pithos.Network { Name = folder + '/'; } + } } -- 1.7.10.4