Fixes for stale states, case insensitive moves
authorpkanavos <pkanavos@gmail.com>
Wed, 13 Jun 2012 20:21:36 +0000 (23:21 +0300)
committerpkanavos <pkanavos@gmail.com>
Wed, 13 Jun 2012 20:21:36 +0000 (23:21 +0300)
Disabled leftover NetworkAgent functionality

trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs
trunk/Pithos.Core/Agents/NetworkAgent.cs
trunk/Pithos.Core/Agents/PollAgent.cs
trunk/Pithos.Core/Agents/Uploader.cs
trunk/Pithos.Core/Agents/WorkflowAgent.cs
trunk/Pithos.Core/PithosMonitor.cs

index 12424b8..1c66f24 100644 (file)
@@ -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
index f511614..759fe82 100644 (file)
@@ -63,7 +63,7 @@ namespace Pithos.Core.Agents
     {
         private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
-        private Agent<CloudAction> _agent;
+        //private Agent<CloudAction> _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<CloudAction> GetEnumerable()
         {
             return _agent.GetEnumerable();
         }
+*/
 
         public Task GetDeleteAwaiter()
         {
             return DeleteAgent.ProceedEvent.WaitAsync();
         }
+/*
         public CancellationToken CancellationToken
         {
             get { return _agent.CancellationToken; }
         }
+*/
 
         public bool Pause
         {
index 5308239..20115f4 100644 (file)
@@ -263,7 +263,7 @@ namespace Pithos.Core.Agents
         private async Task<DateTime?> WaitForScheduledOrManualPoll(DateTime? since)\r
         {\r
             var sync = _syncEvent.WaitAsync();\r
-            var wait = TaskEx.Delay(TimeSpan.FromSeconds(Settings.PollingInterval), NetworkAgent.CancellationToken);\r
+            var wait = TaskEx.Delay(TimeSpan.FromSeconds(Settings.PollingInterval));\r
             \r
             var signaledTask = await TaskEx.WhenAny(sync, wait);\r
             \r
@@ -622,6 +622,11 @@ namespace Pithos.Core.Agents
                                 DeleteCloudFile(accountInfo, tuple);\r
                                 //updateRecord(Remove L, S)                  \r
                             }\r
+                                //If both the local and server files are missing, the state is stale\r
+                            else if (!localInfo.Exists && ( tuple.S==null || tuple.ObjectInfo==null))\r
+                            {\r
+                                StatusKeeper.ClearFileStatus(localInfo.FullName);\r
+                            }\r
                             else\r
                             {\r
                                 ReportConflictForMismatch(localFilePath);\r
@@ -635,10 +640,13 @@ namespace Pithos.Core.Agents
 \r
         private string MoveForServerMove(AccountInfo accountInfo, StateTuple tuple)\r
         {\r
+            if (tuple.ObjectInfo == null)\r
+                return null;\r
             var relativePath = tuple.ObjectInfo.RelativeUrlToFilePath(accountInfo.UserName);\r
             var serverPath = Path.Combine(accountInfo.AccountPath, relativePath);\r
-\r
-            if (tuple.FilePath == serverPath) return serverPath;\r
+            \r
+            //Compare Case Insensitive\r
+            if (String.Equals(tuple.FilePath ,serverPath,StringComparison.InvariantCultureIgnoreCase)) return serverPath;\r
 \r
             if (tuple.FileInfo.Exists)\r
             {                    \r
@@ -1067,9 +1075,10 @@ namespace Pithos.Core.Agents
         public void SetSelectivePaths(AccountInfo accountInfo,Uri[] added, Uri[] removed)\r
         {\r
             AbortRemovedPaths(accountInfo,removed);\r
-            DownloadNewPaths(accountInfo,added);\r
+            //DownloadNewPaths(accountInfo,added);\r
         }\r
 \r
+/*\r
         private void DownloadNewPaths(AccountInfo accountInfo, Uri[] added)\r
         {\r
             var client = new CloudFilesClient(accountInfo);\r
@@ -1122,8 +1131,9 @@ namespace Pithos.Core.Agents
             //Need to get a listing of each of the URLs, then post them to the NetworkAgent\r
             //CreatesToActions(accountInfo,)\r
 \r
-/*            NetworkAgent.Post();*/\r
+/*            NetworkAgent.Post();#1#\r
         }\r
+*/\r
 \r
         private void AbortRemovedPaths(AccountInfo accountInfo, Uri[] removed)\r
         {\r
index ea5f429..5d33012 100644 (file)
@@ -281,8 +281,8 @@ namespace Pithos.Core.Agents
             if (String.IsNullOrWhiteSpace(cloudFile.Container))\r
                 throw new ArgumentException("Invalid container", "cloudFile");\r
             Contract.EndContractBlock();\r
-\r
            \r
+\r
             using (StatusNotification.GetNotifier("Uploading {0}", "Finished Uploading {0}", fileInfo.Name))\r
             {\r
                 if (await WaitOrAbort(accountInfo,cloudFile, token)) \r
index f56afef..d6a77c0 100644 (file)
@@ -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<WorkflowState>.Start(inbox =>
+            /*_agent = Agent<WorkflowState>.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<object> 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#
 
     }
+*/
 }
index ab6ba13..4d4b4ff 100644 (file)
@@ -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);