From 5e64696492a40768cf4712be1151db6fe199778a Mon Sep 17 00:00:00 2001 From: Panagiotis Kanavos Date: Wed, 9 May 2012 12:01:09 +0300 Subject: [PATCH] Modified Selectives.IsSelected(ObjectInfo) to include the user's account, to properly check if selective synchronization is enabled. 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 | 14 +++++++------- trunk/Pithos.Core/Agents/SelectiveUris.cs | 6 +++--- trunk/Pithos.Core/Agents/Uploader.cs | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/trunk/Pithos.Core/Agents/Downloader.cs b/trunk/Pithos.Core/Agents/Downloader.cs index 17931cf..1bc5332 100644 --- a/trunk/Pithos.Core/Agents/Downloader.cs +++ b/trunk/Pithos.Core/Agents/Downloader.cs @@ -54,7 +54,7 @@ namespace Pithos.Core.Agents { // var cancellationToken=_cts.Token;// .ThrowIfCancellationRequested(); - if (await WaitOrAbort(cloudFile, cancellationToken)) + if (await WaitOrAbort(accountInfo,cloudFile, cancellationToken)) return; @@ -65,7 +65,7 @@ namespace Pithos.Core.Agents if (cloudFile.Name.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase)) return; - if (!Selectives.IsSelected(cloudFile)) + if (!Selectives.IsSelected(accountInfo,cloudFile)) return; @@ -154,7 +154,7 @@ namespace Pithos.Core.Agents throw new ArgumentException("cloudFile is a directory, not a file", "cloudFile"); Contract.EndContractBlock(); - if (await WaitOrAbort(cloudFile, cancellationToken)) + if (await WaitOrAbort(accountInfo,cloudFile, cancellationToken)) return; var fileAgent = GetFileAgent(accountInfo); @@ -176,7 +176,7 @@ namespace Pithos.Core.Agents ReportDownloadProgress(Path.GetFileName(localPath), 0, upHashes.Length, cloudFile.Bytes); for (var i = 0; i < upHashes.Length; i++) { - if (await WaitOrAbort(cloudFile, cancellationToken)) + if (await WaitOrAbort(accountInfo,cloudFile, cancellationToken)) return; //For every non-matching hash @@ -238,7 +238,7 @@ namespace Pithos.Core.Agents throw new ArgumentException("cloudFile is a directory, not a file", "cloudFile"); Contract.EndContractBlock(); - if (await WaitOrAbort(cloudFile, cancellationToken)) + if (await WaitOrAbort(accountInfo,cloudFile, cancellationToken)) return; var localPath = FileInfoExtensions.GetProperFilePathCapitalization(filePath); @@ -327,11 +327,11 @@ namespace Pithos.Core.Agents return AgentLocator.Get(accountInfo.AccountPath); } - private async Task WaitOrAbort(ObjectInfo cloudFile, CancellationToken token) + private async Task WaitOrAbort(AccountInfo account,ObjectInfo cloudFile, CancellationToken token) { token.ThrowIfCancellationRequested(); await UnpauseEvent.WaitAsync(); - var shouldAbort = !Selectives.IsSelected(cloudFile); + var shouldAbort = !Selectives.IsSelected(account,cloudFile); if (shouldAbort) Log.InfoFormat("Aborting [{0}]", cloudFile.Uri); return shouldAbort; diff --git a/trunk/Pithos.Core/Agents/SelectiveUris.cs b/trunk/Pithos.Core/Agents/SelectiveUris.cs index 3187f4a..827f2c5 100644 --- a/trunk/Pithos.Core/Agents/SelectiveUris.cs +++ b/trunk/Pithos.Core/Agents/SelectiveUris.cs @@ -61,18 +61,18 @@ namespace Pithos.Core.Agents SelectivePaths[account.AccountKey] = UrisToFilePaths(account,uris); } - public bool IsSelected(ObjectInfo info) + public bool IsSelected(AccountInfo account,ObjectInfo info) { //Shared folders should NOT be synced if selective syncing is disabled var isShared = info.IsShared??false; if (info.StorageUri == null) return true; - var selectiveEnabled = IsSelectiveEnabled(info.AccountKey); + var selectiveEnabled = IsSelectiveEnabled(account.AccountKey); if (!selectiveEnabled) return !isShared; List filterUris; - return !SelectiveUris.TryGetValue(info.AccountKey, out filterUris) + return !SelectiveUris.TryGetValue(account.AccountKey, out filterUris) || filterUris.Count ==0 || filterUris.Any(f => info.Uri.IsAtOrDirectlyBelow(f)); } diff --git a/trunk/Pithos.Core/Agents/Uploader.cs b/trunk/Pithos.Core/Agents/Uploader.cs index 094d2f9..7ac3dd3 100644 --- a/trunk/Pithos.Core/Agents/Uploader.cs +++ b/trunk/Pithos.Core/Agents/Uploader.cs @@ -260,7 +260,7 @@ namespace Pithos.Core.Agents using (StatusNotification.GetNotifier("Uploading {0}", "Finished Uploading {0}", fileInfo.Name)) { - if (await WaitOrAbort(cloudFile, token)) + if (await WaitOrAbort(accountInfo,cloudFile, token)) return; var fullFileName = fileInfo.GetProperCapitalization(); @@ -278,14 +278,14 @@ namespace Pithos.Core.Agents while (missingHashes.Count > 0) { - if (await WaitOrAbort(cloudFile, token)) + if (await WaitOrAbort(accountInfo,cloudFile, token)) return; var buffer = new byte[accountInfo.BlockSize]; foreach (var missingHash in missingHashes) { - if (await WaitOrAbort(cloudFile, token)) + if (await WaitOrAbort(accountInfo,cloudFile, token)) return; @@ -317,11 +317,11 @@ namespace Pithos.Core.Agents } } - private async Task WaitOrAbort(ObjectInfo cloudFile, CancellationToken token) + private async Task WaitOrAbort(AccountInfo account,ObjectInfo cloudFile, CancellationToken token) { token.ThrowIfCancellationRequested(); await UnpauseEvent.WaitAsync(); - var shouldAbort = !Selectives.IsSelected(cloudFile); + var shouldAbort = !Selectives.IsSelected(account,cloudFile); if (shouldAbort) Log.InfoFormat("Aborting [{0}]",cloudFile.Uri); return shouldAbort; -- 1.7.10.4