From 086547e655f9f352bb5844e761b28ec896d0b6bf Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Thu, 18 Feb 2016 17:20:52 +0100 Subject: [PATCH] Implemented the missing details for the concurrent setup, it now compiles --- .../Main/Database/LocalBackupDatabase.cs | 18 +++++-- .../Main/Duplicati.Library.Main.csproj | 1 - .../Library/Main/Operation/BackendProcess.cs | 47 ------------------- .../Main/Operation/Backup/BackupDatabase.cs | 2 +- .../Operation/Backup/BackupStatsCollector.cs | 2 +- .../Main/Operation/Common/BackendHandler.cs | 4 +- 6 files changed, 19 insertions(+), 55 deletions(-) delete mode 100644 Duplicati/Library/Main/Operation/BackendProcess.cs diff --git a/Duplicati/Library/Main/Database/LocalBackupDatabase.cs b/Duplicati/Library/Main/Database/LocalBackupDatabase.cs index 98a6e24f4..92c528dc2 100644 --- a/Duplicati/Library/Main/Database/LocalBackupDatabase.cs +++ b/Duplicati/Library/Main/Database/LocalBackupDatabase.cs @@ -799,13 +799,12 @@ namespace Duplicati.Library.Main.Database } } - public object SafeDeleteRemoteVolume(string name, System.Data.IDbTransaction transaction) + public void SafeDeleteRemoteVolume(string name, System.Data.IDbTransaction transaction) { var volumeid = GetRemoteVolumeID(name, transaction); - using(var cmd = m_connection.CreateCommand()) + using(var cmd = m_connection.CreateCommand(transaction)) { - cmd.Transaction = transaction; var c = cmd.ExecuteNonQuery(@"SELECT COUNT(*) FROM ""Block"" WHERE ""VolumeID"" = ? ", volumeid); if (c != 0) throw new Exception(string.Format("Failed to safe-delete volume {0}, blocks: {1}", name, c)); @@ -813,5 +812,18 @@ namespace Duplicati.Library.Main.Database RemoveRemoteVolume(name, transaction); } } + + public IEnumerable GetBlocklistHashes(string name, System.Data.IDbTransaction transaction) + { + var volumeid = GetRemoteVolumeID(name, transaction); + using(var cmd = m_connection.CreateCommand(transaction)) + { + // Grab the strings and return as array to avoid concurrent access to the IEnumerable + return cmd.ExecuteReaderEnumerable( + @"SELECT DISTINCT ""Block"".""Hash"" FROM ""Block"" WHERE ""Block"".""VolumeID"" = ? AND ""Block"".""Hash"" IN (SELECT ""Hash"" FROM ""BlocklistHash"")", volumeid) + .Select(x => x.ConvertValueToString(0)) + .ToArray(); + } + } } } diff --git a/Duplicati/Library/Main/Duplicati.Library.Main.csproj b/Duplicati/Library/Main/Duplicati.Library.Main.csproj index b61d64f23..b8a631730 100644 --- a/Duplicati/Library/Main/Duplicati.Library.Main.csproj +++ b/Duplicati/Library/Main/Duplicati.Library.Main.csproj @@ -122,7 +122,6 @@ - diff --git a/Duplicati/Library/Main/Operation/BackendProcess.cs b/Duplicati/Library/Main/Operation/BackendProcess.cs deleted file mode 100644 index 6be29a35d..000000000 --- a/Duplicati/Library/Main/Operation/BackendProcess.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2015, The Duplicati Team -// http://www.duplicati.com, info@duplicati.com -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using CoCoL; -using System.Threading.Tasks; -using Duplicati.Library.Main.Operation.Common; - -namespace Duplicati.Library.Main.Operation -{ - internal static class BackendProcess - { - public static Task Run() - { - return AutomationExtensions.RunTask( - new - { - LogChannel = ChannelMarker.ForWrite("LogChannel"), - Input = ChannelMarker.ForRead("BackendRequests"), - }, - - async self => - { - while(true) - { - var request = await self.Input.ReadAsync(); - - } - } - ); - } - } -} - diff --git a/Duplicati/Library/Main/Operation/Backup/BackupDatabase.cs b/Duplicati/Library/Main/Operation/Backup/BackupDatabase.cs index 9f22f0ba4..c3fce1937 100644 --- a/Duplicati/Library/Main/Operation/Backup/BackupDatabase.cs +++ b/Duplicati/Library/Main/Operation/Backup/BackupDatabase.cs @@ -117,7 +117,7 @@ namespace Duplicati.Library.Main.Operation.Backup public Task SafeDeleteRemoteVolumeAsync(string remotename) { - return RunOnMain(() => Task.FromResult(m_database.SafeDeleteRemoteVolume(remotename, m_transaction))); + return RunOnMain(() => m_database.SafeDeleteRemoteVolume(remotename, m_transaction)); } public Task> GetBlocklistHashesAsync(string remotename) diff --git a/Duplicati/Library/Main/Operation/Backup/BackupStatsCollector.cs b/Duplicati/Library/Main/Operation/Backup/BackupStatsCollector.cs index b318937c6..121d46f14 100644 --- a/Duplicati/Library/Main/Operation/Backup/BackupStatsCollector.cs +++ b/Duplicati/Library/Main/Operation/Backup/BackupStatsCollector.cs @@ -25,7 +25,7 @@ namespace Duplicati.Library.Main.Operation.Backup private BackupResults m_res; public BackupStatsCollector(BackupResults res) - : base(res) + : base(res.BackendWriter) { m_res = res; } diff --git a/Duplicati/Library/Main/Operation/Common/BackendHandler.cs b/Duplicati/Library/Main/Operation/Common/BackendHandler.cs index 28edf8e8e..cbe5404c6 100644 --- a/Duplicati/Library/Main/Operation/Common/BackendHandler.cs +++ b/Duplicati/Library/Main/Operation/Common/BackendHandler.cs @@ -267,14 +267,14 @@ namespace Duplicati.Library.Main.Operation.Common }); } - public Task GetFileForTestingAsync(string remotename, long size, string remotehash) + /*public Task GetFileForTestingAsync(string remotename, long size, string remotehash) { var fe = new FileEntryItem(BackendActionType.Get, remotename, null); return RunRetryOnMain(fe, async() => { }); - } + }*/ private async Task ResetBackendAsync(Exception ex) {