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:
authorDean Ferreyra <dean@octw.com>2020-07-19 10:23:24 +0300
committerDean Ferreyra <dean@octw.com>2020-07-19 16:43:30 +0300
commitfd186712b462c853715477ad656dab6a91b2f8c4 (patch)
tree20dd64509f33123775d616fc6e60a21a01bb2a9e /Duplicati/CommandLine
parent6acbbf2136d001f402de63901be34eec2bd041b6 (diff)
Support problematic Windows paths
Change "Duplicati.CommandLine.RecoveryTool restore" to support restoring long paths, and files and directories that end in a dot or a space when run on Windows.
Diffstat (limited to 'Duplicati/CommandLine')
-rw-r--r--Duplicati/CommandLine/RecoveryTool/Restore.cs14
1 files changed, 8 insertions, 6 deletions
diff --git a/Duplicati/CommandLine/RecoveryTool/Restore.cs b/Duplicati/CommandLine/RecoveryTool/Restore.cs
index e4436bec6..b2fc5282e 100644
--- a/Duplicati/CommandLine/RecoveryTool/Restore.cs
+++ b/Duplicati/CommandLine/RecoveryTool/Restore.cs
@@ -25,6 +25,8 @@ namespace Duplicati.CommandLine.RecoveryTool
{
public static class Restore
{
+ private static readonly ISystemIO systemIO = SystemIO.IO_OS;
+
public static int Run(List<string> args, Dictionary<string, string> options, Library.Utility.IFilter filter)
{
if (args.Count != 2 && args.Count != 3)
@@ -158,8 +160,8 @@ namespace Duplicati.CommandLine.RecoveryTool
try
{
var targetfile = MapToRestorePath(f.Path, largestprefix, targetpath);
- if (!Directory.Exists(Path.GetDirectoryName(targetfile)))
- Directory.CreateDirectory(Path.GetDirectoryName(targetfile));
+ if (!systemIO.DirectoryExists(systemIO.PathGetDirectoryName(targetfile)))
+ systemIO.DirectoryCreate(systemIO.PathGetDirectoryName(targetfile));
Console.Write("{0}: {1} ({2})", i, targetfile, Library.Utility.Utility.FormatSizeString(f.Size));
@@ -214,12 +216,12 @@ namespace Duplicati.CommandLine.RecoveryTool
if (fh == f.Hash)
{
Console.WriteLine(" done!");
- File.Copy(tf, targetfile, true);
+ systemIO.FileCopy(tf, targetfile, true);
}
else
{
Console.Write(" - Restored file hash mismatch");
- if (File.Exists(targetfile))
+ if (systemIO.FileExists(targetfile))
Console.WriteLine(" - not overwriting existing file: {0}", targetfile);
else
Console.WriteLine(" - restoring file in damaged condition");
@@ -254,10 +256,10 @@ namespace Duplicati.CommandLine.RecoveryTool
if (path.Substring(1, 1) == ":")
prefixpath = path.Substring(0, 1) + path.Substring(2);
- return Path.Combine(restorepath, prefixpath);
+ return systemIO.PathCombine(restorepath, prefixpath);
}
- return Path.Combine(restorepath, path.Substring(prefixpath.Length));
+ return systemIO.PathCombine(restorepath, path.Substring(prefixpath.Length));
}