From bc053df294672e4d3e44541e99c9875fc879c845 Mon Sep 17 00:00:00 2001
From: verhoek <30193551+verhoek@users.noreply.github.com>
Date: Sat, 27 Oct 2018 12:17:07 +0200
Subject: [PATCH] Moved basic IO helper functions to Library.IO.
---
.../Duplicati.CommandLine.RecoveryTool.csproj | 4 ++
Duplicati/CommandLine/RecoveryTool/Restore.cs | 5 +-
.../Duplicati.GUI.TrayIcon.csproj | 14 +++-
.../HttpServerConnection.cs | 5 +-
.../Duplicati.Library.AutoUpdater.csproj | 4 ++
Duplicati/Library/AutoUpdater/Program.cs | 7 +-
.../Library/AutoUpdater/UpdaterManager.cs | 13 ++--
.../AlternativeFTP/AlternativeFTPBackend.cs | 2 +-
...cati.Library.Backend.AlternativeFTP.csproj | 4 ++
.../Library/Backend/AmazonCloudDrive/AmzCD.cs | 5 +-
...ti.Library.Backend.AmazonCloudDrive.csproj | 4 ++
Duplicati/Library/Backend/Backblaze/B2.cs | 3 +-
...Duplicati.Library.Backend.Backblaze.csproj | 4 ++
Duplicati/Library/Backend/Box/BoxBackend.cs | 3 +-
.../Box/Duplicati.Library.Backend.Box.csproj | 4 ++
.../FTP/Duplicati.Library.Backend.FTP.csproj | 4 ++
Duplicati/Library/Backend/FTP/FTPBackend.cs | 7 +-
Duplicati/Library/Backend/File/FileBackend.cs | 6 +-
...cati.Library.Backend.GoogleServices.csproj | 4 ++
.../GoogleServices/GoogleCloudStorage.cs | 5 +-
.../Backend/GoogleServices/GoogleDrive.cs | 3 +-
...uplicati.Library.Backend.Jottacloud.csproj | 4 ++
.../Library/Backend/Jottacloud/Jottacloud.cs | 5 +-
.../Duplicati.Library.Backend.OneDrive.csproj | 4 ++
.../Library/Backend/OneDrive/OneDrive.cs | 5 +-
...Duplicati.Library.Backend.OpenStack.csproj | 4 ++
.../Backend/OpenStack/OpenStackStorage.cs | 5 +-
.../S3/Duplicati.Library.Backend.S3.csproj | 4 ++
Duplicati/Library/Backend/S3/S3Backend.cs | 7 +-
.../Duplicati.Library.Backend.SSHv2.csproj | 4 ++
.../Library/Backend/SSHv2/SSHv2Backend.cs | 5 +-
...uplicati.Library.Backend.SharePoint.csproj | 4 ++
.../Backend/SharePoint/SharePointBackend.cs | 3 +-
...Duplicati.Library.Backend.TahoeLAFS.csproj | 4 ++
.../Library/Backend/TahoeLAFS/TahoeBackend.cs | 5 +-
.../Duplicati.Library.Backend.WEBDAV.csproj | 4 ++
Duplicati/Library/Backend/WEBDAV/WEBDAV.cs | 9 +--
.../Duplicati.Library.Compression.csproj | 4 ++
.../Compression/FileArchiveDirectory.cs | 7 +-
Duplicati/Library/IO/Util.cs | 64 +++++++++++++++++++
Duplicati/Library/Main/Controller.cs | 7 +-
.../Main/Database/LocalBugReportDatabase.cs | 7 +-
.../Main/Database/LocalListDatabase.cs | 19 +++---
.../Main/Database/LocalRestoreDatabase.cs | 17 ++---
.../Library/Main/Database/PathLookupHelper.cs | 9 +--
.../Library/Main/Operation/BackupHandler.cs | 5 +-
.../Library/Main/Operation/RestoreHandler.cs | 6 +-
.../Duplicati.Library.Snapshots.csproj | 8 ---
Duplicati/Library/Snapshots/USNJournal.cs | 8 +--
.../Library/Snapshots/UsnJournalService.cs | 5 +-
.../Utility/Duplicati.Library.Utility.csproj | 4 ++
Duplicati/Library/Utility/FilterGroups.cs | 5 +-
Duplicati/Library/Utility/TempFolder.cs | 7 +-
Duplicati/Library/Utility/Utility.cs | 56 +++-------------
Duplicati/Server/Program.cs | 7 +-
.../WebServer/RESTMethods/Filesystem.cs | 4 +-
Duplicati/Server/WebServer/Server.cs | 6 +-
Duplicati/UnitTest/Duplicati.UnitTest.csproj | 4 ++
Duplicati/UnitTest/SVNCheckoutsTest.cs | 17 ++---
Duplicati/UnitTest/TestUtils.cs | 9 +--
Duplicati/UnitTest/UtilityTests.cs | 21 +++---
61 files changed, 314 insertions(+), 178 deletions(-)
create mode 100644 Duplicati/Library/IO/Util.cs
diff --git a/Duplicati/CommandLine/RecoveryTool/Duplicati.CommandLine.RecoveryTool.csproj b/Duplicati/CommandLine/RecoveryTool/Duplicati.CommandLine.RecoveryTool.csproj
index 6a21e8313..53796323f 100644
--- a/Duplicati/CommandLine/RecoveryTool/Duplicati.CommandLine.RecoveryTool.csproj
+++ b/Duplicati/CommandLine/RecoveryTool/Duplicati.CommandLine.RecoveryTool.csproj
@@ -171,6 +171,10 @@
{B20A7CEE-9C5B-47B9-8B76-BC85ADFE8493}
Duplicati.Library.Backend.Dropbox
+
+ {D63E53E4-A458-4C2F-914D-92F715F58ACF}
+ Duplicati.Library.IO
+
diff --git a/Duplicati/CommandLine/RecoveryTool/Restore.cs b/Duplicati/CommandLine/RecoveryTool/Restore.cs
index c74167200..de966c415 100644
--- a/Duplicati/CommandLine/RecoveryTool/Restore.cs
+++ b/Duplicati/CommandLine/RecoveryTool/Restore.cs
@@ -18,7 +18,8 @@ using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
-
+using Duplicati.Library.IO;
+
namespace Duplicati.CommandLine.RecoveryTool
{
public static class Restore
@@ -148,7 +149,7 @@ namespace Duplicati.CommandLine.RecoveryTool
Console.WriteLine("Restoring {0} files to {1}", filecount, string.IsNullOrWhiteSpace(targetpath) ? "original position" : targetpath);
if (Library.Utility.Utility.IsClientLinux || largestprefix.Length > 0)
- largestprefix = Library.Utility.Utility.AppendDirSeparator(largestprefix);
+ largestprefix = Util.AppendDirSeparator(largestprefix);
if (!string.IsNullOrEmpty(largestprefix))
Console.WriteLine("Removing common prefix {0} from files", largestprefix);
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj
index 7023768d3..adc121222 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj
@@ -78,12 +78,18 @@
..\..\..\thirdparty\appindicator-sharp\gdk-sharp.dll
+ gtk-sharp-2.0
..\..\..\thirdparty\appindicator-sharp\gtk-sharp.dll
+ gtk-sharp-2.0
+
+
+ glib-sharp-2.0
+
+
+ gtk-sharp-2.0
-
-
..\..\..\thirdparty\MonoMac\MonoMac.dll
@@ -334,6 +340,10 @@
{0797AA22-C5DD-4950-BB60-34765AB8C6DD}
Duplicati.Tools
+
+ {D63E53E4-A458-4C2F-914D-92F715F58ACF}
+ Duplicati.Library.IO
+
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs
index 167010c18..8a7615b23 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs
@@ -1,8 +1,9 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
+using Duplicati.Library.IO;
using Duplicati.Server.Serialization;
using Duplicati.Server.Serialization.Interface;
@@ -76,7 +77,7 @@ namespace Duplicati.GUI.TrayIcon
public HttpServerConnection(Uri server, string password, bool saltedpassword, Program.PasswordSource passwordSource, bool disableTrayIconLogin, Dictionary options)
{
- m_baseUri = Duplicati.Library.Utility.Utility.AppendDirSeparator(server.ToString(), "/");
+ m_baseUri = Util.AppendDirSeparator(server.ToString(), "/");
m_apiUri = m_baseUri + "api/v1";
diff --git a/Duplicati/Library/AutoUpdater/Duplicati.Library.AutoUpdater.csproj b/Duplicati/Library/AutoUpdater/Duplicati.Library.AutoUpdater.csproj
index 99c1279a9..2588f027f 100644
--- a/Duplicati/Library/AutoUpdater/Duplicati.Library.AutoUpdater.csproj
+++ b/Duplicati/Library/AutoUpdater/Duplicati.Library.AutoUpdater.csproj
@@ -67,6 +67,10 @@
{4D012CB1-4B92-47F4-89B7-BF80A73A2E99}
Duplicati.License
+
+ {D63E53E4-A458-4C2F-914D-92F715F58ACF}
+ Duplicati.Library.IO
+
diff --git a/Duplicati/Library/AutoUpdater/Program.cs b/Duplicati/Library/AutoUpdater/Program.cs
index d02781dd4..fd9d31ba1 100644
--- a/Duplicati/Library/AutoUpdater/Program.cs
+++ b/Duplicati/Library/AutoUpdater/Program.cs
@@ -18,7 +18,8 @@
using System;
using System.Linq;
using System.Collections.Generic;
-
+using Duplicati.Library.IO;
+
namespace Duplicati.Library.AutoUpdater
{
public static class Program
@@ -61,7 +62,7 @@ namespace Duplicati.Library.AutoUpdater
{
var versions = UpdaterManager.FindInstalledVersions();
var selfdir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
- if (string.Equals(Library.Utility.Utility.AppendDirSeparator(selfdir), Library.Utility.Utility.AppendDirSeparator(UpdaterManager.InstalledBaseDir)))
+ if (string.Equals(Util.AppendDirSeparator(selfdir), Util.AppendDirSeparator(UpdaterManager.InstalledBaseDir)))
versions = versions.Union(new KeyValuePair[] { new KeyValuePair(selfdir, UpdaterManager.SelfVersion) });
Console.WriteLine(string.Join(Environment.NewLine, versions.Select(x => string.Format(" {0} {1} ({2})", (x.Value.Version == UpdaterManager.SelfVersion.Version ? "*" : "-"), x.Value.Displayname, x.Value.Version))));
return 0;
@@ -71,7 +72,7 @@ namespace Duplicati.Library.AutoUpdater
{
var versions = UpdaterManager.FindInstalledVersions();
var selfdir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
- if (string.Equals(Library.Utility.Utility.AppendDirSeparator(selfdir), Library.Utility.Utility.AppendDirSeparator(UpdaterManager.InstalledBaseDir)))
+ if (string.Equals(Util.AppendDirSeparator(selfdir), Util.AppendDirSeparator(UpdaterManager.InstalledBaseDir)))
versions = versions.Union(new KeyValuePair[] { new KeyValuePair(selfdir, UpdaterManager.SelfVersion) });
Console.WriteLine(string.Join(Environment.NewLine, versions.Select(x => string.Format(" {0} {1} ({2}): {3}", (x.Value.Version == UpdaterManager.SelfVersion.Version ? "*" : "-"), x.Value.Displayname, x.Value.Version, UpdaterManager.VerifyUnpackedFolder(x.Key, x.Value) ? "Valid" : "*** Modified ***"))));
diff --git a/Duplicati/Library/AutoUpdater/UpdaterManager.cs b/Duplicati/Library/AutoUpdater/UpdaterManager.cs
index 961d122e3..be0b9d890 100644
--- a/Duplicati/Library/AutoUpdater/UpdaterManager.cs
+++ b/Duplicati/Library/AutoUpdater/UpdaterManager.cs
@@ -21,7 +21,8 @@ using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Duplicati.Library.Interface;
-
+using Duplicati.Library.IO;
+
namespace Duplicati.Library.AutoUpdater
{
public enum AutoUpdateStrategy
@@ -149,7 +150,7 @@ namespace Duplicati.Library.AutoUpdater
var attempts = new List();
// We do not want to install anything in the basedir, if the application is installed in "ProgramFiles"
- if (!string.IsNullOrWhiteSpace(programfiles) && !InstalledBaseDir.StartsWith(Library.Utility.Utility.AppendDirSeparator(programfiles), StringComparison.Ordinal))
+ if (!string.IsNullOrWhiteSpace(programfiles) && !InstalledBaseDir.StartsWith(Util.AppendDirSeparator(programfiles), StringComparison.Ordinal))
attempts.Add(System.IO.Path.Combine(InstalledBaseDir, "updates"));
if (Library.Utility.Utility.IsClientOSX)
@@ -510,7 +511,7 @@ namespace Duplicati.Library.AutoUpdater
System.IO.Directory.CreateDirectory(targetfolder);
- var tempfolderpath = Duplicati.Library.Utility.Utility.AppendDirSeparator(tempfolder);
+ var tempfolderpath = Util.AppendDirSeparator(tempfolder);
var tempfolderlength = tempfolderpath.Length;
// Would be nice, but does not work :(
@@ -605,9 +606,9 @@ namespace Duplicati.Library.AutoUpdater
var paths = update.Files.Where(x => !x.Ignore).ToDictionary(x => x.Path.Replace('/', System.IO.Path.DirectorySeparatorChar), Library.Utility.Utility.ClientFilenameStringComparer);
paths.Add(manifest.Path, manifest);
- var ignores = (from x in update.Files where x.Ignore select Library.Utility.Utility.AppendDirSeparator(x.Path.Replace('/', System.IO.Path.DirectorySeparatorChar))).ToList();
+ var ignores = (from x in update.Files where x.Ignore select Util.AppendDirSeparator(x.Path.Replace('/', System.IO.Path.DirectorySeparatorChar))).ToList();
- folder = Library.Utility.Utility.AppendDirSeparator(folder);
+ folder = Util.AppendDirSeparator(folder);
var baselen = folder.Length;
foreach (var file in Library.Utility.Utility.EnumerateFileSystemEntries(folder))
@@ -718,7 +719,7 @@ namespace Duplicati.Library.AutoUpdater
var localManifest = remoteManifest.Clone();
localManifest.RemoteURLS = null;
- inputfolder = Duplicati.Library.Utility.Utility.AppendDirSeparator(inputfolder);
+ inputfolder = Util.AppendDirSeparator(inputfolder);
var baselen = inputfolder.Length;
var dirsep = System.IO.Path.DirectorySeparatorChar.ToString();
diff --git a/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs b/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs
index 631dd9ace..c91d54c46 100644
--- a/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs
+++ b/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs
@@ -147,7 +147,7 @@ namespace Duplicati.Library.Backend.AlternativeFTP
_userInfo.Domain = "";
_url = u.SetScheme("ftp").SetQuery(null).SetCredentials(null, null).ToString();
- _url = Duplicati.Library.Utility.Utility.AppendDirSeparator(_url, "/");
+ _url = IO.Util.AppendDirSeparator(_url, "/");
_listVerify = !CoreUtility.ParseBoolOption(options, "disable-upload-verify");
// Process the aftp-data-connection-type option
diff --git a/Duplicati/Library/Backend/AlternativeFTP/Duplicati.Library.Backend.AlternativeFTP.csproj b/Duplicati/Library/Backend/AlternativeFTP/Duplicati.Library.Backend.AlternativeFTP.csproj
index 3acbabe71..fbf41f3ff 100644
--- a/Duplicati/Library/Backend/AlternativeFTP/Duplicati.Library.Backend.AlternativeFTP.csproj
+++ b/Duplicati/Library/Backend/AlternativeFTP/Duplicati.Library.Backend.AlternativeFTP.csproj
@@ -72,6 +72,10 @@
{DE3E5D4C-51AB-4E5E-BEE8-E636CEBFBA65}
Duplicati.Library.Utility
+
+ {D63E53E4-A458-4C2F-914D-92F715F58ACF}
+ Duplicati.Library.IO
+