From 4cc7beea2c9297cfeeb335ffe71b4cc5d1b6d8e9 Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Fri, 14 May 2021 13:27:09 -0700 Subject: [PATCH] Add test for restoring directory containing problematic filenames. --- Duplicati/UnitTest/ProblematicPathTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Duplicati/UnitTest/ProblematicPathTests.cs b/Duplicati/UnitTest/ProblematicPathTests.cs index be7aed09c..85d3cebd8 100644 --- a/Duplicati/UnitTest/ProblematicPathTests.cs +++ b/Duplicati/UnitTest/ProblematicPathTests.cs @@ -274,6 +274,8 @@ namespace Duplicati.UnitTest } Dictionary restoreOptions = new Dictionary(this.TestOptions) {["restore-path"] = this.RESTOREFOLDER}; + + // Restore just the file. using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null)) { IRestoreResults restoreResults = c.Restore(new[] {filePath}); @@ -283,6 +285,18 @@ namespace Duplicati.UnitTest string restoreFilePath = SystemIO.IO_OS.PathCombine(this.RESTOREFOLDER, pathComponent); TestUtils.AssertFilesAreEqual(filePath, restoreFilePath, true, pathComponent); + SystemIO.IO_OS.FileDelete(restoreFilePath); + + // Restore the entire directory. + string pathSpec = $"[{Util.AppendDirSeparator(this.DATAFOLDER)}.*]"; + using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null)) + { + IRestoreResults restoreResults = c.Restore(new[] {pathSpec}); + Assert.AreEqual(0, restoreResults.Errors.Count()); + Assert.AreEqual(0, restoreResults.Warnings.Count()); + } + + TestUtils.AssertDirectoryTreesAreEquivalent(this.DATAFOLDER, this.RESTOREFOLDER, true, pathComponent); } } } \ No newline at end of file