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 Skovhede <kenneth@hexad.dk>2020-12-19 16:44:21 +0300
committerGitHub <noreply@github.com>2020-12-19 16:44:21 +0300
commitca073a2d0c5225998addb9162d8bf54966fc8e15 (patch)
treee319a1dd4df925ec98fd5381b4981c128bafcc27
parent8002d3d22574f142a78129541007c78de2c0b5cd (diff)
parent780f53b89a08ff10f940c4266741e7eb2c890543 (diff)
Merge pull request #4380 from warwickmm/fix_purge_broken_files_dry_run
Fix error encountered during dry-run of purge-broken-files
-rw-r--r--Duplicati/Library/Main/Operation/PurgeBrokenFilesHandler.cs10
-rw-r--r--Duplicati/UnitTest/PurgeTesting.cs19
2 files changed, 23 insertions, 6 deletions
diff --git a/Duplicati/Library/Main/Operation/PurgeBrokenFilesHandler.cs b/Duplicati/Library/Main/Operation/PurgeBrokenFilesHandler.cs
index 7458477c1..e90a44070 100644
--- a/Duplicati/Library/Main/Operation/PurgeBrokenFilesHandler.cs
+++ b/Duplicati/Library/Main/Operation/PurgeBrokenFilesHandler.cs
@@ -85,6 +85,11 @@ namespace Duplicati.Library.Main.Operation
SetCount = db.GetFilesetFileCount(x.Item2, tr)
}).ToArray();
+ if (m_options.Dryrun)
+ tr.Rollback();
+ else
+ tr.Commit();
+
var fully_emptied = compare_list.Where(x => x.RemoveCount == x.SetCount).ToArray();
var to_purge = compare_list.Where(x => x.RemoveCount != x.SetCount).ToArray();
@@ -167,11 +172,6 @@ namespace Duplicati.Library.Main.Operation
}
}
- if (m_options.Dryrun)
- tr.Rollback();
- else
- tr.Commit();
-
m_result.OperationProgressUpdater.UpdateProgress(0.95f);
if (!m_options.Dryrun && db.RepairInProgress)
diff --git a/Duplicati/UnitTest/PurgeTesting.cs b/Duplicati/UnitTest/PurgeTesting.cs
index 69dea326f..d35d3dc1e 100644
--- a/Duplicati/UnitTest/PurgeTesting.cs
+++ b/Duplicati/UnitTest/PurgeTesting.cs
@@ -20,6 +20,7 @@ using System.IO;
using System.Linq;
using Duplicati.Library.Common.IO;
using Duplicati.Library.Interface;
+using Duplicati.Library.Main;
using Duplicati.Library.Utility;
using NUnit.Framework;
@@ -260,6 +261,15 @@ namespace Duplicati.UnitTest
Assert.AreEqual(affectedfiles[i], files);
}
+ // A dry-run should run without exceptions (see issue #4379).
+ Dictionary<string, string> dryRunOptions = new Dictionary<string, string>(testopts) {["dry-run"] = "true"};
+ using (Controller c = new Controller("file://" + this.TARGETFOLDER, dryRunOptions, null))
+ {
+ IPurgeBrokenFilesResults purgeResults = c.PurgeBrokenFiles(null);
+ Assert.AreEqual(0, purgeResults.Errors.Count());
+ Assert.AreEqual(0, purgeResults.Warnings.Count());
+ }
+
using (var c = new Library.Main.Controller("file://" + TARGETFOLDER, testopts, null))
{
var brk = c.PurgeBrokenFiles(null);
@@ -274,7 +284,14 @@ namespace Duplicati.UnitTest
Assert.AreEqual(3, modFilesets);
}
- }
+ // A subsequent backup should be successful.
+ using (Controller c = new Controller("file://" + this.TARGETFOLDER, testopts, null))
+ {
+ IBackupResults backupResults = c.Backup(new[] {this.DATAFOLDER});
+ Assert.AreEqual(0, backupResults.Errors.Count());
+ Assert.AreEqual(0, backupResults.Warnings.Count());
+ }
+ }
}
}