From 1a41e9ec4f09e3670be11cb03991b87562be614a Mon Sep 17 00:00:00 2001 From: pkanavos Date: Mon, 9 Apr 2012 20:56:02 +0300 Subject: [PATCH] Fixed incorrect account key in PollAgent.cs Fixed incorrect check for Uri and Path relations in CollectionExtensions.cs --- .../SelectiveSynch/SelectiveSynchViewModel.cs | 2 +- trunk/Pithos.Core.Test/Pithos.Core.Test.csproj | 1 + trunk/Pithos.Core/Agents/CollectionExtensions.cs | 8 +++-- trunk/Pithos.Core/Agents/PollAgent.cs | 8 ++--- trunk/Pithos.Core/Agents/SnapshotDifferencer.cs | 10 +++--- trunk/Pithos.Interfaces/PermissionConverter.cs | 12 +++++-- trunk/Pithos.sln | 33 ++++++++++++++++++++ 7 files changed, 60 insertions(+), 14 deletions(-) diff --git a/trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs b/trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs index 00ce722..71074a8 100644 --- a/trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs +++ b/trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs @@ -103,7 +103,7 @@ namespace Pithos.Client.WPF.SelectiveSynch select new DirectoryRecord { DisplayName = container.Name, - Uri=new Uri(client.StorageUrl,container.Name), + Uri=new Uri(client.StorageUrl,String.Format(@"{0}/{1}",Account.AccountName, container.Name)), Directories = (from dir in client.ListObjects(_monitor.UserName, container.Name) where dir.Content_Type == DirectoryType select dir).ToTree() diff --git a/trunk/Pithos.Core.Test/Pithos.Core.Test.csproj b/trunk/Pithos.Core.Test/Pithos.Core.Test.csproj index 4b91404..31c33ac 100644 --- a/trunk/Pithos.Core.Test/Pithos.Core.Test.csproj +++ b/trunk/Pithos.Core.Test/Pithos.Core.Test.csproj @@ -203,6 +203,7 @@ + diff --git a/trunk/Pithos.Core/Agents/CollectionExtensions.cs b/trunk/Pithos.Core/Agents/CollectionExtensions.cs index b4e92c5..2a785cc 100644 --- a/trunk/Pithos.Core/Agents/CollectionExtensions.cs +++ b/trunk/Pithos.Core/Agents/CollectionExtensions.cs @@ -166,8 +166,9 @@ namespace Pithos.Core.Agents //If the uri is below the root, it should match the root's segments one by one //If there is any root segment that doesn't match its corresponding target segment, //the target is not below the root + //DON'T FORGET that Uri segments include the slashes. Must remove them to ensure proper checks var mismatch = rootSegments - .Where((t, i) => !String.Equals(targetSegments[i], t)) + .Where((t, i) => !String.Equals(targetSegments[i].TrimEnd('/'), t.TrimEnd('/'))) .Any(); return !mismatch; } @@ -187,6 +188,8 @@ namespace Pithos.Core.Agents throw new ArgumentNullException("target"); Contract.EndContractBlock(); + if (target.Equals(root)) + return true; return //If the target is directly below the root, it will have exactly //one segment more than the root @@ -229,7 +232,8 @@ namespace Pithos.Core.Agents throw new ArgumentNullException("rootPath"); Contract.EndContractBlock(); - + if (targetPath==rootPath) + return true; var targetSegments = targetPath.Split('\\'); var rootSegments = rootPath.Split('\\'); diff --git a/trunk/Pithos.Core/Agents/PollAgent.cs b/trunk/Pithos.Core/Agents/PollAgent.cs index 3a4a2bf..55f1a4d 100644 --- a/trunk/Pithos.Core/Agents/PollAgent.cs +++ b/trunk/Pithos.Core/Agents/PollAgent.cs @@ -87,7 +87,7 @@ namespace Pithos.Core.Agents private readonly AsyncManualResetEvent _syncEvent = new AsyncManualResetEvent(); private readonly ConcurrentDictionary _lastSeen = new ConcurrentDictionary(); - private readonly ConcurrentDictionary _accounts = new ConcurrentDictionary(); + private readonly ConcurrentDictionary _accounts = new ConcurrentDictionary(); /// @@ -614,15 +614,15 @@ namespace Pithos.Core.Agents public void AddAccount(AccountInfo accountInfo) { //Avoid adding a duplicate accountInfo - _accounts.TryAdd(accountInfo.UserName, accountInfo); + _accounts.TryAdd(accountInfo.AccountKey, accountInfo); } public void RemoveAccount(AccountInfo accountInfo) { AccountInfo account; - _accounts.TryRemove(accountInfo.UserName,out account); + _accounts.TryRemove(accountInfo.AccountKey, out account); SnapshotDifferencer differencer; - _differencer.Differencers.TryRemove(accountInfo.UserName, out differencer); + _differencer.Differencers.TryRemove(accountInfo.AccountKey, out differencer); } } } diff --git a/trunk/Pithos.Core/Agents/SnapshotDifferencer.cs b/trunk/Pithos.Core/Agents/SnapshotDifferencer.cs index 2725e72..c340529 100644 --- a/trunk/Pithos.Core/Agents/SnapshotDifferencer.cs +++ b/trunk/Pithos.Core/Agents/SnapshotDifferencer.cs @@ -39,6 +39,8 @@ * ----------------------------------------------------------------------- */ #endregion + +using System; using System.Collections.Concurrent; using System.Diagnostics.Contracts; using Pithos.Interfaces; @@ -214,17 +216,17 @@ namespace Pithos.Core.Agents public class AccountsDifferencer { - readonly ConcurrentDictionary _differencers = new ConcurrentDictionary(); + readonly ConcurrentDictionary _differencers = new ConcurrentDictionary(); - public ConcurrentDictionary Differencers { get { return _differencers; } } + public ConcurrentDictionary Differencers { get { return _differencers; } } public SnapshotDifferencer PostSnapshot(AccountInfo accountInfo, List cleanRemotes) { SnapshotDifferencer differencer; - if (!_differencers.TryGetValue(accountInfo.UserName, out differencer)) + if (!_differencers.TryGetValue(accountInfo.AccountKey, out differencer)) { differencer = new SnapshotDifferencer(); - _differencers[accountInfo.UserName] = differencer; + _differencers[accountInfo.AccountKey] = differencer; } differencer.Post(cleanRemotes); return differencer; diff --git a/trunk/Pithos.Interfaces/PermissionConverter.cs b/trunk/Pithos.Interfaces/PermissionConverter.cs index f179225..b9da9ae 100644 --- a/trunk/Pithos.Interfaces/PermissionConverter.cs +++ b/trunk/Pithos.Interfaces/PermissionConverter.cs @@ -69,12 +69,18 @@ namespace Pithos.Interfaces var permissionString= (string) reader.Value; + var permissions = ParsePermissions(permissionString); + + return permissions; + } + + public static Dictionary ParsePermissions(string permissionString) + { var permissions = (from permisson in permissionString.Split(';') let parsed = permisson.Split('=') from account in parsed[1].Split(',') - select new { account, Permission = parsed[0] }) - .ToDictionary(perm=>perm.account,perm=>perm.Permission); - + select new {account, Permission = parsed[0]}) + .Distinct().ToDictionary(perm => perm.account, perm => perm.Permission); return permissions; } diff --git a/trunk/Pithos.sln b/trunk/Pithos.sln index 2db5942..0aea32e 100644 --- a/trunk/Pithos.sln +++ b/trunk/Pithos.sln @@ -43,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetSparkle2010", "NetSparkl EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.Client.WPF.Test", "Pithos.Client.WPF.Test\Pithos.Client.WPF.Test.csproj", "{7B5BFE77-FC4D-43B3-84A0-9CB457238951}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.Interfaces.Test", "Pithos.Interfaces.Test\Pithos.Interfaces.Test.csproj", "{881F7260-CA40-40FD-AEEC-860B346DC2DC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug All|Any CPU = Debug All|Any CPU @@ -564,6 +566,36 @@ Global {7B5BFE77-FC4D-43B3-84A0-9CB457238951}.Test|Mixed Platforms.Build.0 = Release|Any CPU {7B5BFE77-FC4D-43B3-84A0-9CB457238951}.Test|x64.ActiveCfg = Release|Any CPU {7B5BFE77-FC4D-43B3-84A0-9CB457238951}.Test|x86.ActiveCfg = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|Any CPU.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|Any CPU.Build.0 = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|Mixed Platforms.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|Mixed Platforms.Build.0 = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|x64.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|x86.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|x64.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|x86.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|Any CPU.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|Any CPU.Build.0 = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|x64.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|x86.ActiveCfg = Debug|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|Any CPU.Build.0 = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|x64.ActiveCfg = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|x86.ActiveCfg = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Any CPU.ActiveCfg = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Any CPU.Build.0 = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Mixed Platforms.ActiveCfg = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Mixed Platforms.Build.0 = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|x64.ActiveCfg = Release|Any CPU + {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -574,5 +606,6 @@ Global {E027200B-C26A-4877-BFD9-1A18CF5DF2F4} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095} {F9AF3E97-BCB7-46B7-8014-7FC858AEE9BA} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095} {7B5BFE77-FC4D-43B3-84A0-9CB457238951} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095} + {881F7260-CA40-40FD-AEEC-860B346DC2DC} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095} EndGlobalSection EndGlobal -- 1.7.10.4