Modified Selectives.IsSelected(ObjectInfo) to include the user's account, to properly...
authorPanagiotis Kanavos <pkanavos@gmail.com>
Wed, 9 May 2012 09:01:09 +0000 (12:01 +0300)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Wed, 9 May 2012 09:01:09 +0000 (12:01 +0300)
ObjectInfo includes the account info of the target file, not the user's account and fails for shared files

trunk/Pithos.Core/Agents/Downloader.cs
trunk/Pithos.Core/Agents/SelectiveUris.cs
trunk/Pithos.Core/Agents/Uploader.cs

index 17931cf..1bc5332 100644 (file)
@@ -54,7 +54,7 @@ namespace Pithos.Core.Agents
                 {\r
                    // var cancellationToken=_cts.Token;//  .ThrowIfCancellationRequested();\r
 \r
-                    if (await WaitOrAbort(cloudFile, cancellationToken))\r
+                    if (await WaitOrAbort(accountInfo,cloudFile, cancellationToken))\r
                         return;\r
 \r
 \r
@@ -65,7 +65,7 @@ namespace Pithos.Core.Agents
                     if (cloudFile.Name.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase))\r
                         return;\r
 \r
-                    if (!Selectives.IsSelected(cloudFile))\r
+                    if (!Selectives.IsSelected(accountInfo,cloudFile))\r
                         return;\r
 \r
 \r
@@ -154,7 +154,7 @@ namespace Pithos.Core.Agents
                 throw new ArgumentException("cloudFile is a directory, not a file", "cloudFile");\r
             Contract.EndContractBlock();\r
 \r
-            if (await WaitOrAbort(cloudFile, cancellationToken))\r
+            if (await WaitOrAbort(accountInfo,cloudFile, cancellationToken))\r
                 return;\r
 \r
             var fileAgent = GetFileAgent(accountInfo);\r
@@ -176,7 +176,7 @@ namespace Pithos.Core.Agents
             ReportDownloadProgress(Path.GetFileName(localPath), 0, upHashes.Length, cloudFile.Bytes);\r
             for (var i = 0; i < upHashes.Length; i++)\r
             {\r
-                if (await WaitOrAbort(cloudFile, cancellationToken))\r
+                if (await WaitOrAbort(accountInfo,cloudFile, cancellationToken))\r
                     return;\r
 \r
                 //For every non-matching hash\r
@@ -238,7 +238,7 @@ namespace Pithos.Core.Agents
                 throw new ArgumentException("cloudFile is a directory, not a file", "cloudFile");\r
             Contract.EndContractBlock();\r
 \r
-            if (await WaitOrAbort(cloudFile, cancellationToken))\r
+            if (await WaitOrAbort(accountInfo,cloudFile, cancellationToken))\r
                 return;\r
 \r
             var localPath = FileInfoExtensions.GetProperFilePathCapitalization(filePath);\r
@@ -327,11 +327,11 @@ namespace Pithos.Core.Agents
             return AgentLocator<FileAgent>.Get(accountInfo.AccountPath);\r
         }\r
 \r
-        private async Task<bool> WaitOrAbort(ObjectInfo cloudFile, CancellationToken token)\r
+        private async Task<bool> WaitOrAbort(AccountInfo account,ObjectInfo cloudFile, CancellationToken token)\r
         {\r
             token.ThrowIfCancellationRequested();\r
             await UnpauseEvent.WaitAsync();\r
-            var shouldAbort = !Selectives.IsSelected(cloudFile);\r
+            var shouldAbort = !Selectives.IsSelected(account,cloudFile);\r
             if (shouldAbort)\r
                 Log.InfoFormat("Aborting [{0}]", cloudFile.Uri);\r
             return shouldAbort;\r
index 3187f4a..827f2c5 100644 (file)
@@ -61,18 +61,18 @@ namespace Pithos.Core.Agents
             SelectivePaths[account.AccountKey] = UrisToFilePaths(account,uris);\r
         }\r
 \r
-        public bool IsSelected(ObjectInfo info)\r
+        public bool IsSelected(AccountInfo account,ObjectInfo info)\r
         {\r
             //Shared folders should NOT be synced if selective syncing is disabled\r
             var isShared = info.IsShared??false;\r
             if (info.StorageUri == null)\r
                 return true;\r
-            var selectiveEnabled = IsSelectiveEnabled(info.AccountKey);\r
+            var selectiveEnabled = IsSelectiveEnabled(account.AccountKey);\r
             if (!selectiveEnabled)\r
                 return !isShared;\r
 \r
             List<Uri> filterUris;\r
-            return !SelectiveUris.TryGetValue(info.AccountKey, out filterUris) \r
+            return !SelectiveUris.TryGetValue(account.AccountKey, out filterUris) \r
                 || filterUris.Count ==0\r
                 || filterUris.Any(f => info.Uri.IsAtOrDirectlyBelow(f));\r
         }\r
index 094d2f9..7ac3dd3 100644 (file)
@@ -260,7 +260,7 @@ namespace Pithos.Core.Agents
            \r
             using (StatusNotification.GetNotifier("Uploading {0}", "Finished Uploading {0}", fileInfo.Name))\r
             {\r
-                if (await WaitOrAbort(cloudFile, token)) \r
+                if (await WaitOrAbort(accountInfo,cloudFile, token)) \r
                     return;\r
 \r
                 var fullFileName = fileInfo.GetProperCapitalization();\r
@@ -278,14 +278,14 @@ namespace Pithos.Core.Agents
                 while (missingHashes.Count > 0)\r
                 {\r
 \r
-                    if (await WaitOrAbort(cloudFile, token))\r
+                    if (await WaitOrAbort(accountInfo,cloudFile, token))\r
                         return;\r
 \r
 \r
                     var buffer = new byte[accountInfo.BlockSize];\r
                     foreach (var missingHash in missingHashes)\r
                     {\r
-                        if (await WaitOrAbort(cloudFile, token))\r
+                        if (await WaitOrAbort(accountInfo,cloudFile, token))\r
                             return;\r
 \r
 \r
@@ -317,11 +317,11 @@ namespace Pithos.Core.Agents
             }\r
         }\r
 \r
-        private async Task<bool> WaitOrAbort(ObjectInfo cloudFile, CancellationToken token)\r
+        private async Task<bool> WaitOrAbort(AccountInfo account,ObjectInfo cloudFile, CancellationToken token)\r
         {\r
             token.ThrowIfCancellationRequested();\r
             await UnpauseEvent.WaitAsync();\r
-            var shouldAbort = !Selectives.IsSelected(cloudFile);\r
+            var shouldAbort = !Selectives.IsSelected(account,cloudFile);\r
             if (shouldAbort)\r
                 Log.InfoFormat("Aborting [{0}]",cloudFile.Uri);\r
             return shouldAbort;\r