Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Hsu <kennethhsu@gmail.com>2020-07-21 19:19:01 +0300
committerKenneth Hsu <kennethhsu@gmail.com>2020-07-21 22:59:28 +0300
commitfea55b998107617d3efbbeb5a5a2a4107f229622 (patch)
tree507232f97369054fea8ef08863e34c3d080eebc9 /Duplicati/Library/Main/Controller.cs
parent47df16063ff1a9ba377807d77a83735c9016ca44 (diff)
Avoid removing files unrelated to backup being deleted.
This fixes issues #3845 and #4244.
Diffstat (limited to 'Duplicati/Library/Main/Controller.cs')
-rw-r--r--Duplicati/Library/Main/Controller.cs17
1 files changed, 15 insertions, 2 deletions
diff --git a/Duplicati/Library/Main/Controller.cs b/Duplicati/Library/Main/Controller.cs
index ea2c93dce..18669a994 100644
--- a/Duplicati/Library/Main/Controller.cs
+++ b/Duplicati/Library/Main/Controller.cs
@@ -25,6 +25,7 @@ using Duplicati.Library.Utility;
using Duplicati.Library.Common.IO;
using Duplicati.Library.Common;
using Duplicati.Library.Interface;
+using Duplicati.Library.Main.Database;
namespace Duplicati.Library.Main
{
@@ -205,8 +206,6 @@ namespace Duplicati.Library.Main
return RunAction(new ListRemoteResults(), (result) =>
{
result.OperationProgressUpdater.UpdatePhase(OperationPhase.Delete_Listing);
- using (var tf = System.IO.File.Exists(m_options.Dbpath) ? null : new Library.Utility.TempFile())
- using (var db = new Database.LocalDatabase(((string)tf) ?? m_options.Dbpath, "list-remote", true))
using (var bk = new BackendManager(m_backend, m_options, result.BackendWriter, null))
{
// Only delete files that match the expected pattern and prefix
@@ -216,6 +215,20 @@ namespace Duplicati.Library.Main
.Where(x => x.Prefix == m_options.Prefix)
.ToList();
+ // If the local database is available, we will use it to avoid deleting unrelated files
+ // from the backend. Otherwise, we may accidentally delete non-Duplicati files, or
+ // files from a different Duplicati configuration that points to the same backend location
+ // and uses the same prefix (see issues #2678, #3845, and #4244).
+ if (System.IO.File.Exists(m_options.Dbpath))
+ {
+ using (LocalDatabase db = new LocalDatabase(m_options.Dbpath, "list-remote", true))
+ {
+ IEnumerable<RemoteVolumeEntry> dbRemoteVolumes = db.GetRemoteVolumes();
+ HashSet<string> dbRemoteFiles = new HashSet<string>(dbRemoteVolumes.Select(x => x.Name));
+ list = list.Where(x => dbRemoteFiles.Contains(x.File.Name)).ToList();
+ }
+ }
+
result.OperationProgressUpdater.UpdatePhase(OperationPhase.Delete_Deleting);
result.OperationProgressUpdater.UpdateProgress(0);
for (var i = 0; i < list.Count; i++)