From 7bbe511f3141f09d95516217a64c8a09fd3fefed Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Thu, 2 Jul 2020 15:39:56 -0700 Subject: [PATCH] Reduce scope of Controller instance. --- Duplicati/UnitTest/RestoreHandlerTests.cs | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Duplicati/UnitTest/RestoreHandlerTests.cs b/Duplicati/UnitTest/RestoreHandlerTests.cs index a7bd48d75..265c0ee0e 100644 --- a/Duplicati/UnitTest/RestoreHandlerTests.cs +++ b/Duplicati/UnitTest/RestoreHandlerTests.cs @@ -34,21 +34,21 @@ namespace Duplicati.UnitTest using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null)) { c.Restore(new[] {filePath}); - - // We need to strip the root part of the path. Otherwise, Path.Combine will simply return the second argument - // if it's determined to be an absolute path. - string rootString = SystemIO.IO_OS.GetPathRoot(filePath); - string newPathPart = filePath.Substring(rootString.Length); - if (Platform.IsClientWindows) - { - // On windows, the drive letter is included in the path when the dont-compress-restore-paths option is used. - // The drive letter is assumed to be the first character of the path root (e.g., C:\). - newPathPart = Path.Combine(rootString.Substring(0, 1), filePath.Substring(rootString.Length)); - } - - string restoredFilePath = Path.Combine(restoreOptions["restore-path"], newPathPart); - Assert.IsTrue(File.Exists(restoredFilePath)); } + + // We need to strip the root part of the path. Otherwise, Path.Combine will simply return the second argument + // if it's determined to be an absolute path. + string rootString = SystemIO.IO_OS.GetPathRoot(filePath); + string newPathPart = filePath.Substring(rootString.Length); + if (Platform.IsClientWindows) + { + // On windows, the drive letter is included in the path when the dont-compress-restore-paths option is used. + // The drive letter is assumed to be the first character of the path root (e.g., C:\). + newPathPart = Path.Combine(rootString.Substring(0, 1), filePath.Substring(rootString.Length)); + } + + string restoredFilePath = Path.Combine(restoreOptions["restore-path"], newPathPart); + Assert.IsTrue(File.Exists(restoredFilePath)); } [Test]