Changes to delete check order
authorPanagiotis Kanavos <pkanavos@gmail.com>
Wed, 11 Jan 2012 17:55:37 +0000 (19:55 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Wed, 11 Jan 2012 17:55:37 +0000 (19:55 +0200)
trunk/Pithos.Core/Agents/NetworkAgent.cs
trunk/Pithos.Core/Agents/StatusAgent.cs

index bef5599..584532c 100644 (file)
@@ -60,7 +60,7 @@ namespace Pithos.Core.Agents
 
         //A separate agent is used to execute delete actions immediatelly;
         private Agent<CloudDeleteAction> _deleteAgent;
-        ConcurrentDictionary<string,DateTime> _deletedFiles=new ConcurrentDictionary<string, DateTime>();
+        readonly ConcurrentDictionary<string,DateTime> _deletedFiles=new ConcurrentDictionary<string, DateTime>();
 
         [System.ComponentModel.Composition.Import]
         public IStatusKeeper StatusKeeper { get; set; }
@@ -120,38 +120,42 @@ namespace Pithos.Core.Agents
                 try
                 {
 
-                    switch (action.Action)
+                    if (action.Action == CloudActionType.DeleteCloud)
                     {
-                        case CloudActionType.UploadUnconditional:
-                            //Abort if the file was deleted before we reached this point
-                            if (!IsDeletedFile(action))
+                        //Redirect deletes to the delete agent 
+                        _deleteAgent.Post((CloudDeleteAction)action);                        
+                    }
+                    if (IsDeletedFile(action))
+                    {
+                        //Clear the status of already deleted files to avoid reprocessing
+                        this.StatusKeeper.ClearFileStatus(action.LocalFile.FullName);
+                    }
+                    else
+                    {
+                        switch (action.Action)
+                        {
+                            case CloudActionType.UploadUnconditional:
+                                //Abort if the file was deleted before we reached this point
                                 await UploadCloudFile(action);
-                            break;
-                        case CloudActionType.DownloadUnconditional:
-                            if (!IsDeletedFile(action))
+                                break;
+                            case CloudActionType.DownloadUnconditional:
                                 await DownloadCloudFile(accountInfo, cloudFile, downloadPath);
-                            break;
-                        case CloudActionType.DeleteCloud:
-                            //Redirect deletes to the delete agent 
-                            _deleteAgent.Post((CloudDeleteAction)action);
-                            break;
-                        case CloudActionType.RenameCloud:
-                            var moveAction = (CloudMoveAction)action;
-                            if (!IsDeletedFile(action))
+                                break;
+                            case CloudActionType.RenameCloud:
+                                var moveAction = (CloudMoveAction) action;
                                 RenameCloudFile(accountInfo, moveAction);
-                            break;
-                        case CloudActionType.MustSynch:
-                            if (!File.Exists(downloadPath) && !Directory.Exists(downloadPath))
-                            {
-                                if (!IsDeletedFile(action))
+                                break;
+                            case CloudActionType.MustSynch:
+                                if (!File.Exists(downloadPath) && !Directory.Exists(downloadPath))
+                                {
                                     await DownloadCloudFile(accountInfo, cloudFile, downloadPath);
-                            }
-                            else
-                            {
-                                if (!IsDeletedFile(action))
+                                }
+                                else
+                                {
                                     await SyncFiles(accountInfo, action);
-                            }
-                            break;
+                                }
+                                break;
+                        }
                     }
                     Log.InfoFormat("[ACTION] End Processing {0}:{1}->{2}", action.Action, action.LocalFile,
                                            action.CloudFile.Name);
index 974f983..67dafb2 100644 (file)
@@ -406,7 +406,7 @@ namespace Pithos.Core.Agents
 
         private string GetConnectionString()
         {
-            var connectionString = String.Format(@"Data Source={0}\pithos.db;Version=3;Enlist=N;Pooling=True;Default Isolation Level=ReadCommited;show_sql=true", _pithosDataPath);
+            var connectionString = String.Format(@"Data Source={0}\pithos.db;Version=3;Enlist=N;Pooling=True", _pithosDataPath);
             return connectionString;
         }