From 14ecd267215d811ba0b586fd1bd1baa0ab482de5 Mon Sep 17 00:00:00 2001 From: Panagiotis Kanavos Date: Wed, 11 Jan 2012 19:55:37 +0200 Subject: [PATCH] Changes to delete check order --- trunk/Pithos.Core/Agents/NetworkAgent.cs | 58 ++++++++++++++++-------------- trunk/Pithos.Core/Agents/StatusAgent.cs | 2 +- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/trunk/Pithos.Core/Agents/NetworkAgent.cs b/trunk/Pithos.Core/Agents/NetworkAgent.cs index bef5599..584532c 100644 --- a/trunk/Pithos.Core/Agents/NetworkAgent.cs +++ b/trunk/Pithos.Core/Agents/NetworkAgent.cs @@ -60,7 +60,7 @@ namespace Pithos.Core.Agents //A separate agent is used to execute delete actions immediatelly; private Agent _deleteAgent; - ConcurrentDictionary _deletedFiles=new ConcurrentDictionary(); + readonly ConcurrentDictionary _deletedFiles=new ConcurrentDictionary(); [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); diff --git a/trunk/Pithos.Core/Agents/StatusAgent.cs b/trunk/Pithos.Core/Agents/StatusAgent.cs index 974f983..67dafb2 100644 --- a/trunk/Pithos.Core/Agents/StatusAgent.cs +++ b/trunk/Pithos.Core/Agents/StatusAgent.cs @@ -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; } -- 1.7.10.4