From: pkanavos Date: Wed, 13 Jun 2012 20:21:36 +0000 (+0300) Subject: Fixes for stale states, case insensitive moves X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/commitdiff_plain/9036d725882deab5711f6f1c5af594d4e45f0de2 Fixes for stale states, case insensitive moves Disabled leftover NetworkAgent functionality --- diff --git a/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs b/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs index 12424b8..1c66f24 100644 --- a/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs +++ b/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs @@ -76,7 +76,7 @@ namespace Pithos.Client.WPF.FileProperties select new CloudDownloadAction(account, info, "Resolver"); downloadActions.Apply(action=> StatusAgent.SetFileState(action.FileState.FilePath,FileStatus.Unchanged,FileOverlayStatus.Normal,"Resolve by downloading")); - downloadActions.Apply(NetworkAgent.Post); + //downloadActions.Apply(NetworkAgent.Post); } @@ -97,7 +97,7 @@ namespace Pithos.Client.WPF.FileProperties account.BlockSize, account.BlockHash,"Resolver",false); actions.Apply(action => StatusAgent.SetFileState(action.FileState.FilePath, FileStatus.Modified, FileOverlayStatus.Normal, "Resolve by downloading")); - actions.Apply(NetworkAgent.Post); + //actions.Apply(NetworkAgent.Post); } //Keeping both versions means that we need to copy one of them diff --git a/trunk/Pithos.Core/Agents/NetworkAgent.cs b/trunk/Pithos.Core/Agents/NetworkAgent.cs index f511614..759fe82 100644 --- a/trunk/Pithos.Core/Agents/NetworkAgent.cs +++ b/trunk/Pithos.Core/Agents/NetworkAgent.cs @@ -63,7 +63,7 @@ namespace Pithos.Core.Agents { private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Agent _agent; + //private Agent _agent; [System.ComponentModel.Composition.Import] public DeleteAgent DeleteAgent { get; set; } @@ -154,7 +154,7 @@ namespace Pithos.Core.Agents } - public void Start() + /*public void Start() { if (_agent != null) return; @@ -176,8 +176,9 @@ namespace Pithos.Core.Agents loop(); }); - } + }*/ +/* private async Task Process(CloudAction action) { if (action == null) @@ -262,7 +263,7 @@ namespace Pithos.Core.Agents Log.WarnFormat("[REQUEUE] {0} : {1} -> {2}", action.Action, action.LocalFile, action.CloudFile); } } -*/ +#1# catch (OperationCanceledException ex) { Log.WarnFormat("Cancelling [{0}]",ex); @@ -296,8 +297,9 @@ namespace Pithos.Core.Agents } } } +*/ - private void ProcessChildUploads(CloudUploadAction uploadAction) + /* private void ProcessChildUploads(CloudUploadAction uploadAction) { if (!uploadAction.IsCreation || !(uploadAction.LocalFile is DirectoryInfo)) return; @@ -317,7 +319,8 @@ namespace Pithos.Core.Agents folderActions.ApplyAction(PostUploadAction); fileActions.ApplyAction(PostUploadAction); } - +*/ +/* private void PostUploadAction(CloudUploadAction action) { var state = StatusKeeper.GetStateByFilePath(action.LocalFile.FullName); @@ -332,8 +335,9 @@ namespace Pithos.Core.Agents action.FileState = state; Post(action); } +*/ - private CancellationToken CurrentOperationCancelToken + public CancellationToken CurrentOperationCancelToken { get { return _currentOperationCancellation.Token; } } @@ -483,6 +487,7 @@ namespace Pithos.Core.Agents StatusNotification.NotifyChange(message, TraceLevel.Warning); } +/* public void Post(CloudAction cloudAction) { if (cloudAction == null) @@ -498,21 +503,26 @@ namespace Pithos.Core.Agents else _agent.Post(cloudAction); } +*/ +/* public IEnumerable GetEnumerable() { return _agent.GetEnumerable(); } +*/ public Task GetDeleteAwaiter() { return DeleteAgent.ProceedEvent.WaitAsync(); } +/* public CancellationToken CancellationToken { get { return _agent.CancellationToken; } } +*/ public bool Pause { diff --git a/trunk/Pithos.Core/Agents/PollAgent.cs b/trunk/Pithos.Core/Agents/PollAgent.cs index 5308239..20115f4 100644 --- a/trunk/Pithos.Core/Agents/PollAgent.cs +++ b/trunk/Pithos.Core/Agents/PollAgent.cs @@ -263,7 +263,7 @@ namespace Pithos.Core.Agents private async Task WaitForScheduledOrManualPoll(DateTime? since) { var sync = _syncEvent.WaitAsync(); - var wait = TaskEx.Delay(TimeSpan.FromSeconds(Settings.PollingInterval), NetworkAgent.CancellationToken); + var wait = TaskEx.Delay(TimeSpan.FromSeconds(Settings.PollingInterval)); var signaledTask = await TaskEx.WhenAny(sync, wait); @@ -622,6 +622,11 @@ namespace Pithos.Core.Agents DeleteCloudFile(accountInfo, tuple); //updateRecord(Remove L, S) } + //If both the local and server files are missing, the state is stale + else if (!localInfo.Exists && ( tuple.S==null || tuple.ObjectInfo==null)) + { + StatusKeeper.ClearFileStatus(localInfo.FullName); + } else { ReportConflictForMismatch(localFilePath); @@ -635,10 +640,13 @@ namespace Pithos.Core.Agents private string MoveForServerMove(AccountInfo accountInfo, StateTuple tuple) { + if (tuple.ObjectInfo == null) + return null; var relativePath = tuple.ObjectInfo.RelativeUrlToFilePath(accountInfo.UserName); var serverPath = Path.Combine(accountInfo.AccountPath, relativePath); - - if (tuple.FilePath == serverPath) return serverPath; + + //Compare Case Insensitive + if (String.Equals(tuple.FilePath ,serverPath,StringComparison.InvariantCultureIgnoreCase)) return serverPath; if (tuple.FileInfo.Exists) { @@ -1067,9 +1075,10 @@ namespace Pithos.Core.Agents public void SetSelectivePaths(AccountInfo accountInfo,Uri[] added, Uri[] removed) { AbortRemovedPaths(accountInfo,removed); - DownloadNewPaths(accountInfo,added); + //DownloadNewPaths(accountInfo,added); } +/* private void DownloadNewPaths(AccountInfo accountInfo, Uri[] added) { var client = new CloudFilesClient(accountInfo); @@ -1122,8 +1131,9 @@ namespace Pithos.Core.Agents //Need to get a listing of each of the URLs, then post them to the NetworkAgent //CreatesToActions(accountInfo,) -/* NetworkAgent.Post();*/ +/* NetworkAgent.Post();#1# } +*/ private void AbortRemovedPaths(AccountInfo accountInfo, Uri[] removed) { diff --git a/trunk/Pithos.Core/Agents/Uploader.cs b/trunk/Pithos.Core/Agents/Uploader.cs index ea5f429..5d33012 100644 --- a/trunk/Pithos.Core/Agents/Uploader.cs +++ b/trunk/Pithos.Core/Agents/Uploader.cs @@ -281,8 +281,8 @@ namespace Pithos.Core.Agents if (String.IsNullOrWhiteSpace(cloudFile.Container)) throw new ArgumentException("Invalid container", "cloudFile"); Contract.EndContractBlock(); - + using (StatusNotification.GetNotifier("Uploading {0}", "Finished Uploading {0}", fileInfo.Name)) { if (await WaitOrAbort(accountInfo,cloudFile, token)) diff --git a/trunk/Pithos.Core/Agents/WorkflowAgent.cs b/trunk/Pithos.Core/Agents/WorkflowAgent.cs index f56afef..d6a77c0 100644 --- a/trunk/Pithos.Core/Agents/WorkflowAgent.cs +++ b/trunk/Pithos.Core/Agents/WorkflowAgent.cs @@ -56,6 +56,7 @@ using log4net; namespace Pithos.Core.Agents { +/* [Export] public class WorkflowAgent { @@ -78,7 +79,7 @@ namespace Pithos.Core.Agents public WorkflowAgent() { - _agent = Agent.Start(inbox => + /*_agent = Agent.Start(inbox => { Action loop = null; loop = () => @@ -89,9 +90,10 @@ namespace Pithos.Core.Agents Log.ErrorFormat("[ERROR] Synch for {0}:\r{1}", message.Result.FileName, ex)); }; loop(); - }); + });#1# } +/* private Task Process(WorkflowState state) { var accountInfo = state.AccountInfo; @@ -173,7 +175,9 @@ namespace Pithos.Core.Agents } } } +#1# +/* private void DeleteChildObjects(WorkflowState state, FileState fileState) { @@ -189,6 +193,7 @@ namespace Pithos.Core.Agents } } } +#1# /*private void MoveChildObjects(WorkflowState state) { @@ -213,10 +218,11 @@ namespace Pithos.Core.Agents oldMoveInfo, newMoveInfo)); } } - }*/ + }#1# //Starts interrupted files for a specific account +/* public void RestartInterruptedFiles(AccountInfo accountInfo) { @@ -255,9 +261,11 @@ namespace Pithos.Core.Agents pendingStates.ForEach(Post); } } +#1# +/* public void Post(WorkflowState workflowState) { if (Log.IsDebugEnabled) @@ -266,7 +274,7 @@ namespace Pithos.Core.Agents //Remove invalid state //For now, ignore paths /* if (Directory.Exists(workflowState.Path)) - return;*/ + return;#2# //TODO: Need to handle folder renames @@ -283,6 +291,8 @@ namespace Pithos.Core.Agents _agent.Post(workflowState); } +#1# } +*/ } diff --git a/trunk/Pithos.Core/PithosMonitor.cs b/trunk/Pithos.Core/PithosMonitor.cs index ab6ba13..4d4b4ff 100644 --- a/trunk/Pithos.Core/PithosMonitor.cs +++ b/trunk/Pithos.Core/PithosMonitor.cs @@ -102,6 +102,7 @@ namespace Pithos.Core //[Import] public FileAgent FileAgent { get; private set; } +/* private WorkflowAgent _workflowAgent; [Import] @@ -114,6 +115,7 @@ namespace Pithos.Core //FileAgent.WorkflowAgent = value; } } +*/ [Import] public NetworkAgent NetworkAgent { get; set; } @@ -214,7 +216,7 @@ namespace Pithos.Core //TODO; Warn user? return; - WorkflowAgent.StatusNotification = StatusNotification; + //WorkflowAgent.StatusNotification = StatusNotification; StatusNotification.NotifyChange("Starting"); if (_started) @@ -262,7 +264,7 @@ namespace Pithos.Core StartNetworkAgent(); - WorkflowAgent.RestartInterruptedFiles(_accountInfo); + //WorkflowAgent.RestartInterruptedFiles(_accountInfo); _started = true; } @@ -357,7 +359,9 @@ namespace Pithos.Core //TODO: The Network and Poll agents are not account specific //They should be moved outside PithosMonitor +/* NetworkAgent.Start(); +*/ PollAgent.AddAccount(_accountInfo);