Update Telegram SharpAESCrypt dep Update SystemIOWindows to split the difference # Conflicts: # BuildTools/AutoUpdateBuilder/AutoUpdateBuilder.csproj # BuildTools/AutoUpdateBuilder/packages.config # BuildTools/DependencyFinder/DependencyFinder.csproj # BuildTools/DependencyFinder/packages.config # BuildTools/GnupgSigningTool/GnupgSigningTool.csproj # BuildTools/UpdateVersionStamp/UpdateVersionStamp.csproj # BuildTools/UpdateVersionStamp/app.config # Duplicati/CommandLine/BackendTester/Duplicati.CommandLine.BackendTester.csproj # Duplicati/CommandLine/BackendTester/app.config # Duplicati/CommandLine/BackendTool/Duplicati.CommandLine.BackendTool.csproj # Duplicati/CommandLine/BackendTool/app.config # Duplicati/CommandLine/ConfigurationImporter/Duplicati.CommandLine.ConfigurationImporter.csproj # Duplicati/CommandLine/Duplicati.CommandLine.csproj # Duplicati/CommandLine/RecoveryTool/Duplicati.CommandLine.RecoveryTool.csproj # Duplicati/CommandLine/RecoveryTool/packages.config # Duplicati/CommandLine/app.config # Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj # Duplicati/GUI/Duplicati.GUI.TrayIcon/app.config # Duplicati/GUI/Duplicati.GUI.TrayIcon/packages.config # Duplicati/Library/AutoUpdater/Duplicati.Library.AutoUpdater.csproj # Duplicati/Library/AutoUpdater/app.config # Duplicati/Library/AutoUpdater/packages.config # Duplicati/Library/Backend/AlternativeFTP/Duplicati.Library.Backend.AlternativeFTP.csproj # Duplicati/Library/Backend/AlternativeFTP/app.config # Duplicati/Library/Backend/AlternativeFTP/packages.config # Duplicati/Library/Backend/AzureBlob/Duplicati.Library.Backend.AzureBlob.csproj # Duplicati/Library/Backend/AzureBlob/packages.config # Duplicati/Library/Backend/Backblaze/Duplicati.Library.Backend.Backblaze.csproj # Duplicati/Library/Backend/Backblaze/packages.config # Duplicati/Library/Backend/Box/Duplicati.Library.Backend.Box.csproj # Duplicati/Library/Backend/Box/packages.config # Duplicati/Library/Backend/CloudFiles/Duplicati.Library.Backend.CloudFiles.csproj # Duplicati/Library/Backend/CloudFiles/app.config # Duplicati/Library/Backend/Dropbox/Duplicati.Library.Backend.Dropbox.csproj # Duplicati/Library/Backend/Dropbox/packages.config # Duplicati/Library/Backend/FTP/Duplicati.Library.Backend.FTP.csproj # Duplicati/Library/Backend/FTP/app.config # Duplicati/Library/Backend/File/Duplicati.Library.Backend.File.csproj # Duplicati/Library/Backend/File/app.config # Duplicati/Library/Backend/GoogleServices/Duplicati.Library.Backend.GoogleServices.csproj # Duplicati/Library/Backend/GoogleServices/packages.config # Duplicati/Library/Backend/HubiC/Duplicati.Library.Backend.HubiC.csproj # Duplicati/Library/Backend/Jottacloud/Duplicati.Library.Backend.Jottacloud.csproj # Duplicati/Library/Backend/Mega/Duplicati.Library.Backend.Mega.csproj # Duplicati/Library/Backend/Mega/packages.config # Duplicati/Library/Backend/OAuthHelper/Duplicati.Library.OAuthHelper.csproj # Duplicati/Library/Backend/OAuthHelper/packages.config # Duplicati/Library/Backend/OneDrive/Duplicati.Library.Backend.OneDrive.csproj # Duplicati/Library/Backend/OneDrive/packages.config # Duplicati/Library/Backend/OpenStack/Duplicati.Library.Backend.OpenStack.csproj # Duplicati/Library/Backend/OpenStack/packages.config # Duplicati/Library/Backend/Rclone/Duplicati.Library.Backend.Rclone.csproj # Duplicati/Library/Backend/Rclone/packages.config # Duplicati/Library/Backend/S3/Duplicati.Library.Backend.S3.csproj # Duplicati/Library/Backend/S3/app.config # Duplicati/Library/Backend/S3/packages.config # Duplicati/Library/Backend/SSHv2/Duplicati.Library.Backend.SSHv2.csproj # Duplicati/Library/Backend/SSHv2/packages.config # Duplicati/Library/Backend/SharePoint/Duplicati.Library.Backend.SharePoint.csproj # Duplicati/Library/Backend/SharePoint/app.config # Duplicati/Library/Backend/Sia/Duplicati.Library.Backend.Sia.csproj # Duplicati/Library/Backend/Sia/packages.config # Duplicati/Library/Backend/TahoeLAFS/Duplicati.Library.Backend.TahoeLAFS.csproj # Duplicati/Library/Backend/TahoeLAFS/packages.config # Duplicati/Library/Backend/Tardigrade/Duplicati.Library.Backend.Tardigrade.csproj # Duplicati/Library/Backend/Tardigrade/packages.config # Duplicati/Library/Backend/WEBDAV/Duplicati.Library.Backend.WEBDAV.csproj # Duplicati/Library/Backend/WEBDAV/app.config # Duplicati/Library/Common/Duplicati.Library.Common.csproj # Duplicati/Library/Common/IO/SystemIOWindows.cs # Duplicati/Library/Common/app.config # Duplicati/Library/Common/packages.config # Duplicati/Library/Compression/Duplicati.Library.Compression.csproj # Duplicati/Library/Compression/app.config # Duplicati/Library/Compression/packages.config # Duplicati/Library/DynamicLoader/Duplicati.Library.DynamicLoader.csproj # Duplicati/Library/DynamicLoader/app.config # Duplicati/Library/Encryption/Duplicati.Library.Encryption.csproj # Duplicati/Library/Encryption/packages.config # Duplicati/Library/Interface/Duplicati.Library.Interface.csproj # Duplicati/Library/Localization/Duplicati.Library.Localization.csproj # Duplicati/Library/Localization/packages.config # Duplicati/Library/Logging/Duplicati.Library.Logging.csproj # Duplicati/Library/Logging/app.config # Duplicati/Library/Main/Duplicati.Library.Main.csproj # Duplicati/Library/Main/app.config # Duplicati/Library/Main/packages.config # Duplicati/Library/Modules/Builtin/Duplicati.Library.Modules.Builtin.csproj # Duplicati/Library/Modules/Builtin/packages.config # Duplicati/Library/SQLiteHelper/Duplicati.Library.SQLiteHelper.csproj # Duplicati/Library/Snapshots/Duplicati.Library.Snapshots.csproj # Duplicati/Library/Snapshots/app.config # Duplicati/Library/Snapshots/packages.config # Duplicati/Library/UsageReporter/Duplicati.Library.UsageReporter.csproj # Duplicati/Library/UsageReporter/packages.config # Duplicati/Library/Utility/Duplicati.Library.Utility.csproj # Duplicati/Library/Utility/app.config # Duplicati/Library/Utility/packages.config # Duplicati/License/Duplicati.License.csproj # Duplicati/Server/Duplicati.Server.Serialization/Duplicati.Server.Serialization.csproj # Duplicati/Server/Duplicati.Server.Serialization/packages.config # Duplicati/Server/Duplicati.Server.csproj # Duplicati/Server/app.config # Duplicati/Server/packages.config # Duplicati/Service/Duplicati.Service.csproj # Duplicati/Service/app.config # Duplicati/Tools/Duplicati.Tools.csproj # Duplicati/UnitTest/Duplicati.UnitTest.csproj # Duplicati/UnitTest/RestoreHandlerTests.cs # Duplicati/UnitTest/app.config # Duplicati/UnitTest/packages.config # Duplicati/WindowsService/App.config # Duplicati/WindowsService/WindowsService.csproj # Tools/SQLiteTool/App.config # Tools/SQLiteTool/SQLiteTool.csproj # thirdparty/TlsTest/TlsTest.csproj # thirdparty/UnixSupport/UnixSupport.csproj # thirdparty/mozroots/mozroots.csproj
123 lines
5.7 KiB
C#
123 lines
5.7 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Duplicati.Library.Common;
|
|
using Duplicati.Library.Common.IO;
|
|
using Duplicati.Library.Interface;
|
|
using Duplicati.Library.Main;
|
|
using NUnit.Framework;
|
|
|
|
namespace Duplicati.UnitTest
|
|
{
|
|
public class RestoreHandlerTests : BasicSetupHelper
|
|
{
|
|
[Test]
|
|
[Category("RestoreHandler")]
|
|
public void RestoreEmptyFile()
|
|
{
|
|
string folderPath = Path.Combine(this.DATAFOLDER, "folder");
|
|
Directory.CreateDirectory(folderPath);
|
|
string filePath = Path.Combine(folderPath, "empty_file");
|
|
File.WriteAllBytes(filePath, new byte[] { });
|
|
|
|
Dictionary<string, string> options = new Dictionary<string, string>(this.TestOptions);
|
|
using (Controller c = new Controller("file://" + this.TARGETFOLDER, options, null))
|
|
{
|
|
IBackupResults backupResults = c.Backup(new[] {this.DATAFOLDER});
|
|
Assert.AreEqual(0, backupResults.Errors.Count());
|
|
Assert.AreEqual(0, backupResults.Warnings.Count());
|
|
}
|
|
|
|
// Issue #4148 described a situation where the folders containing the empty file were not recreated properly.
|
|
Dictionary<string, string> restoreOptions = new Dictionary<string, string>(this.TestOptions)
|
|
{
|
|
["restore-path"] = this.RESTOREFOLDER,
|
|
["dont-compress-restore-paths"] = "true"
|
|
};
|
|
using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null))
|
|
{
|
|
IRestoreResults restoreResults = c.Restore(new[] {filePath});
|
|
Assert.AreEqual(0, restoreResults.Errors.Count());
|
|
Assert.AreEqual(0, restoreResults.Warnings.Count());
|
|
}
|
|
|
|
// 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]
|
|
[Category("RestoreHandler")]
|
|
public void RestoreInheritanceBreaks()
|
|
{
|
|
if (!Platform.IsClientWindows)
|
|
{
|
|
return;
|
|
}
|
|
/* TODO-DNC
|
|
string folderPath = Path.Combine(this.DATAFOLDER, "folder");
|
|
Directory.CreateDirectory(folderPath);
|
|
string filePath = Path.Combine(folderPath, "file");
|
|
File.WriteAllBytes(filePath, new byte[] {0});
|
|
|
|
// Protect access rules on the file.
|
|
FileSecurity fileSecurity = File.GetAccessControl(filePath);
|
|
fileSecurity.SetAccessRuleProtection(true, true);
|
|
File.SetAccessControl(filePath, fileSecurity);
|
|
|
|
Dictionary<string, string> options = new Dictionary<string, string>(this.TestOptions);
|
|
using (Controller c = new Controller("file://" + this.TARGETFOLDER, options, null))
|
|
{
|
|
IBackupResults backupResults = c.Backup(new[] {this.DATAFOLDER});
|
|
Assert.AreEqual(0, backupResults.Errors.Count());
|
|
Assert.AreEqual(0, backupResults.Warnings.Count());
|
|
}
|
|
|
|
// First, restore without restoring permissions.
|
|
Dictionary<string, string> restoreOptions = new Dictionary<string, string>(this.TestOptions) {["restore-path"] = this.RESTOREFOLDER};
|
|
using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null))
|
|
{
|
|
IRestoreResults restoreResults = c.Restore(new[] {filePath});
|
|
Assert.AreEqual(0, restoreResults.Errors.Count());
|
|
Assert.AreEqual(0, restoreResults.Warnings.Count());
|
|
|
|
string restoredFilePath = Path.Combine(this.RESTOREFOLDER, "file");
|
|
Assert.IsTrue(File.Exists(restoredFilePath));
|
|
|
|
FileSecurity restoredFileSecurity = File.GetAccessControl(restoredFilePath);
|
|
Assert.IsFalse(restoredFileSecurity.AreAccessRulesProtected);
|
|
|
|
// Remove the restored file so that the later restore avoids the "Restore completed
|
|
// without errors but no files were restored" warning.
|
|
File.Delete(restoredFilePath);
|
|
}
|
|
|
|
// Restore with restoring permissions.
|
|
restoreOptions["overwrite"] = "true";
|
|
restoreOptions["restore-permissions"] = "true";
|
|
using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null))
|
|
{
|
|
IRestoreResults restoreResults = c.Restore(new[] {filePath});
|
|
Assert.AreEqual(0, restoreResults.Errors.Count());
|
|
Assert.AreEqual(0, restoreResults.Warnings.Count());
|
|
|
|
string restoredFilePath = Path.Combine(this.RESTOREFOLDER, "file");
|
|
Assert.IsTrue(File.Exists(restoredFilePath));
|
|
|
|
FileSecurity restoredFileSecurity = File.GetAccessControl(restoredFilePath);
|
|
Assert.IsTrue(restoredFileSecurity.AreAccessRulesProtected);
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
} |