Reduced dynamic scanning with static linking.

Cleaned up some `proj` files.
Added caching to options.
This commit is contained in:
Kenneth Skovhede
2024-04-26 14:32:41 +02:00
parent e927e7230d
commit 8e25c6e2ab
39 changed files with 726 additions and 563 deletions
@@ -7,31 +7,16 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Library\Backends\Duplicati.Library.Backends.csproj" />
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Interface\Duplicati.Library.Interface.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj">
</ProjectReference>
<ProjectReference Include="..\..\License\Duplicati.License.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Backend\OAuthHelper\Duplicati.Library.OAuthHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Localization\Duplicati.Library.Localization.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Logging\Duplicati.Library.Logging.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Common\Duplicati.Library.Common.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Compression\Duplicati.Library.Compression.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj" />
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj" />
<ProjectReference Include="..\..\License\Duplicati.License.csproj" />
<ProjectReference Include="..\..\Library\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj" />
<ProjectReference Include="..\..\Library\Backend\OAuthHelper\Duplicati.Library.OAuthHelper.csproj" />
<ProjectReference Include="..\..\Library\Localization\Duplicati.Library.Localization.csproj" />
<ProjectReference Include="..\..\Library\Logging\Duplicati.Library.Logging.csproj" />
<ProjectReference Include="..\..\Library\Common\Duplicati.Library.Common.csproj" />
<ProjectReference Include="..\..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj" />
</ItemGroup>
<ItemGroup>
@@ -6,17 +6,10 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Library\Backends\Duplicati.Library.Backends.csproj" />
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Interface\Duplicati.Library.Interface.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj">
</ProjectReference>
<ProjectReference Include="..\..\License\Duplicati.License.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj" />
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj" />
<ProjectReference Include="..\..\License\Duplicati.License.csproj" />
</ItemGroup>
<ItemGroup>
@@ -8,41 +8,19 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Library\Backends\Duplicati.Library.Backends.csproj" />
<ProjectReference Include="..\..\Library\Compression\Duplicati.Library.Compression.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Common\Duplicati.Library.Common.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Encryption\Duplicati.Library.Encryption.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Interface\Duplicati.Library.Interface.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Logging\Duplicati.Library.Logging.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Main\Duplicati.Library.Main.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj">
</ProjectReference>
<ProjectReference Include="..\..\License\Duplicati.License.csproj">
</ProjectReference>
<ProjectReference Include="..\BackendTool\Duplicati.CommandLine.BackendTool.csproj">
</ProjectReference>
<ProjectReference Include="..\BackendTester\Duplicati.CommandLine.BackendTester.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Localization\Duplicati.Library.Localization.csproj">
</ProjectReference>
<ProjectReference Include="..\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\UsageReporter\Duplicati.Library.UsageReporter.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Tools\Duplicati.Tools.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\..\Library\Common\Duplicati.Library.Common.csproj" />
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj" />
<ProjectReference Include="..\..\Library\Logging\Duplicati.Library.Logging.csproj" />
<ProjectReference Include="..\..\Library\Main\Duplicati.Library.Main.csproj" />
<ProjectReference Include="..\..\License\Duplicati.License.csproj" />
<ProjectReference Include="..\BackendTool\Duplicati.CommandLine.BackendTool.csproj" />
<ProjectReference Include="..\BackendTester\Duplicati.CommandLine.BackendTester.csproj" />
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj" />
<ProjectReference Include="..\..\Library\Localization\Duplicati.Library.Localization.csproj" />
<ProjectReference Include="..\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj" />
<ProjectReference Include="..\..\Library\UsageReporter\Duplicati.Library.UsageReporter.csproj" />
<ProjectReference Include="..\..\Tools\Duplicati.Tools.csproj" />
</ItemGroup>
<ItemGroup>
@@ -7,21 +7,10 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Backends\Duplicati.Library.Backends.csproj" />
<ProjectReference Include="..\..\Library\Compression\Duplicati.Library.Compression.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Encryption\Duplicati.Library.Encryption.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Interface\Duplicati.Library.Interface.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Main\Duplicati.Library.Main.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj" />
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj" />
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\..\Library\Main\Duplicati.Library.Main.csproj" />
</ItemGroup>
<ItemGroup>
@@ -51,52 +51,25 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Library\Backends\Duplicati.Library.Backends.csproj" />
<ProjectReference Include="..\..\Library\Backend\OAuthHelper\Duplicati.Library.OAuthHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Common\Duplicati.Library.Common.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Server\Duplicati.Server.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Server\Duplicati.Server.Serialization\Duplicati.Server.Serialization.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Interface\Duplicati.Library.Interface.csproj">
</ProjectReference>
<ProjectReference Include="..\..\CommandLine\CLI\Duplicati.CommandLine.csproj">
</ProjectReference>
<ProjectReference Include="..\..\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj">
</ProjectReference>
<ProjectReference Include="..\..\CommandLine\BackendTool\Duplicati.CommandLine.BackendTool.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Compression\Duplicati.Library.Compression.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Encryption\Duplicati.Library.Encryption.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Logging\Duplicati.Library.Logging.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Main\Duplicati.Library.Main.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Snapshots\Duplicati.Library.Snapshots.csproj">
</ProjectReference>
<ProjectReference Include="..\..\License\Duplicati.License.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Localization\Duplicati.Library.Localization.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj">
</ProjectReference>
<ProjectReference Include="..\..\CommandLine\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\UsageReporter\Duplicati.Library.UsageReporter.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Tools\Duplicati.Tools.csproj">
</ProjectReference>
<ProjectReference Include="..\..\Library\Backend\OAuthHelper\Duplicati.Library.OAuthHelper.csproj" />
<ProjectReference Include="..\..\Library\Common\Duplicati.Library.Common.csproj" />
<ProjectReference Include="..\..\Server\Duplicati.Server.csproj" />
<ProjectReference Include="..\..\Server\Duplicati.Server.Serialization\Duplicati.Server.Serialization.csproj" />
<ProjectReference Include="..\..\Library\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\..\Library\Interface\Duplicati.Library.Interface.csproj" />
<ProjectReference Include="..\..\CommandLine\CLI\Duplicati.CommandLine.csproj" />
<ProjectReference Include="..\..\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj" />
<ProjectReference Include="..\..\CommandLine\BackendTool\Duplicati.CommandLine.BackendTool.csproj" />
<ProjectReference Include="..\..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj" />
<ProjectReference Include="..\..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj" />
<ProjectReference Include="..\..\Library\Logging\Duplicati.Library.Logging.csproj" />
<ProjectReference Include="..\..\Library\Main\Duplicati.Library.Main.csproj" />
<ProjectReference Include="..\..\Library\Snapshots\Duplicati.Library.Snapshots.csproj" />
<ProjectReference Include="..\..\License\Duplicati.License.csproj" />
<ProjectReference Include="..\..\Library\Localization\Duplicati.Library.Localization.csproj" />
<ProjectReference Include="..\..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj" />
<ProjectReference Include="..\..\CommandLine\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj" />
<ProjectReference Include="..\..\Library\UsageReporter\Duplicati.Library.UsageReporter.csproj" />
<ProjectReference Include="..\..\Tools\Duplicati.Tools.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,62 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
using Duplicati.Library.Interface;
namespace Duplicati.Library.Backends;
public static class BackendModules
{
/// <summary>
/// The list of all built-in backend modules
/// </summary>
public static IReadOnlyList<IBackend> BuiltInBackendModules => [
new Backend.AliyunOSS.OSS(),
new Backend.AlternativeFTP.AlternativeFtpBackend(),
new Backend.AzureBlob.AzureBlobBackend(),
new Backend.Backblaze.B2(),
new Backend.Box.BoxBackend(),
new Backend.CloudFiles(),
new Backend.Dropbox(),
new Backend.FTP(),
new Backend.File(),
new Backend.GoogleCloudStorage.GoogleCloudStorage(),
new Backend.GoogleDrive.GoogleDrive(),
new Backend.Idrivee2Backend(),
new Backend.Jottacloud(),
new Backend.Mega.MegaBackend(),
new Backend.MicrosoftGroup(),
new Backend.OneDriveV2(),
new Backend.OpenStack.OpenStackStorage(),
new Backend.Rclone(),
new Backend.S3(),
new Backend.SSHv2(),
new Backend.OneDriveForBusinessBackend(),
new Backend.SharePointBackend(),
new Backend.SharePointV2(),
new Backend.Sia.Sia(),
new Backend.Storj.Storj(),
new Backend.TahoeBackend(),
new Backend.TencentCOS.COS(),
new Backend.WEBDAV()
];
}
@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Description>Central reference to all backends</Description>
<RootNamespace>Duplicati.Library.Backend</RootNamespace>
</PropertyGroup>
<ItemGroup>
@@ -28,5 +29,6 @@
<ProjectReference Include="..\Backend\TahoeLAFS\Duplicati.Library.Backend.TahoeLAFS.csproj" />
<ProjectReference Include="..\Backend\TencentCOS\Duplicati.Library.Backend.TencentCOS.csproj" />
<ProjectReference Include="..\Backend\WEBDAV\Duplicati.Library.Backend.WEBDAV.csproj" />
<ProjectReference Include="..\Backend\AliyunOSS\Duplicati.Library.Backend.AliyunOSS.csproj" />
</ItemGroup>
</Project>
+41
View File
@@ -0,0 +1,41 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
using Duplicati.Library.Interface;
namespace Duplicati.Library.Backend;
public static class WebModules
{
/// <summary>
/// The list of all built-in web modules
/// </summary>
public static IReadOnlyList<IWebModule> BuiltInWebModules => [
new GoogleServices.GCSConfig(),
new OpenStack.SwiftConfig(),
new S3Config(),
new S3IAM(),
new KeyGenerator(),
new KeyUploader(),
new Storj.StorjConfig(),
];
}
@@ -0,0 +1,36 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
using Duplicati.Library.Interface;
namespace Duplicati.Library.Compression;
public static class CompressionModules
{
/// <summary>
/// The list of all built-in compression modules
/// </summary>
public static IReadOnlyList<ICompression> BuiltInCompressionModules => [
new FileArchiveZip(),
new SevenZipCompression()
];
}
@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>Duplicati.Library.Compression</RootNamespace>
</PropertyGroup>
<ItemGroup>
@@ -1,32 +1,30 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using Duplicati.Library.Interface;
using System.Collections.Specialized;
using System.Web;
using System.Linq;
using System.Runtime.ExceptionServices;
using Duplicati.Library.Backends;
namespace Duplicati.Library.DynamicLoader
{
@@ -53,10 +51,12 @@ namespace Duplicati.Library.DynamicLoader
/// <summary>
/// Returns the subfolders searched for backends
/// </summary>
protected override string[] Subfolders
{
get { return new string[] {"backends"}; }
}
protected override string[] Subfolders => ["backends"];
/// <summary>
/// The built-in modules
/// </summary>
protected override IEnumerable<IBackend> BuiltInModules => BackendModules.BuiltInBackendModules;
/// <summary>
/// Instanciates a specific backend, given the url and options
@@ -67,9 +67,9 @@ namespace Duplicati.Library.DynamicLoader
public IBackend GetBackend(string url, Dictionary<string, string> options)
{
var uri = new Utility.Uri(url);
LoadInterfaces();
var newOpts = new Dictionary<string, string>(options);
foreach (var key in uri.QueryParameters.AllKeys)
newOpts[key] = uri.QueryParameters[key];
@@ -108,7 +108,7 @@ namespace Duplicati.Library.DynamicLoader
throw;
}
return null;
}
}
@@ -118,27 +118,28 @@ namespace Duplicati.Library.DynamicLoader
/// </summary>
/// <param name="url">The url to find commands for</param>
/// <returns>The supported commands or null if the url scheme was not supported</returns>
public IList<ICommandLineArgument> GetSupportedCommands(string url)
public IReadOnlyList<ICommandLineArgument> GetSupportedCommands(string url)
{
var uri = new Utility.Uri(url);
LoadInterfaces();
// TODO: The loading logic is replicated in the "GetBackend" method, should be refactored
lock (m_lock)
{
IBackend b;
if (m_interfaces.TryGetValue(uri.Scheme, out b) && b != null)
return b.SupportedCommands;
return GetSupportedCommandsCached(b).ToList();
else if (uri.Scheme.EndsWith("s", StringComparison.Ordinal))
{
var tmpscheme = uri.Scheme.Substring(0, uri.Scheme.Length - 1);
if (m_interfaces.ContainsKey(tmpscheme))
return m_interfaces[tmpscheme].SupportedCommands;
if (m_interfaces.TryGetValue(tmpscheme, out b) && b != null)
return GetSupportedCommandsCached(b).ToList();
}
return null;
}
}
}
}
/// <summary>
@@ -152,18 +153,18 @@ namespace Duplicati.Library.DynamicLoader
/// Gets a list of loaded backends, the instances can be used to extract interface information, not used to interact with the backend.
/// </summary>
public static IBackend[] Backends { get { return _backendLoader.Interfaces; } }
/// <summary>
/// Gets a list of keys supported
/// </summary>
public static string[] Keys { get { return _backendLoader.Keys; } }
/// <summary>
/// Gets the supported commands for a given backend
/// </summary>
/// <param name="url">The url to find the commands for</param>
/// <returns>The supported commands or null if the url is not supported</returns>
public static IList<ICommandLineArgument> GetSupportedCommands(string url)
public static IReadOnlyList<ICommandLineArgument> GetSupportedCommands(string url)
{
if (string.IsNullOrEmpty(url))
throw new ArgumentNullException(nameof(url));
@@ -1,28 +1,29 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using Duplicati.Library.Compression;
using Duplicati.Library.Interface;
namespace Duplicati.Library.DynamicLoader
@@ -50,10 +51,12 @@ namespace Duplicati.Library.DynamicLoader
/// <summary>
/// Returns the subfolders searched for compression modules
/// </summary>
protected override string[] Subfolders
{
get { return new string[] { "compression" }; }
}
protected override string[] Subfolders => ["compression"];
/// <summary>
/// The built-in modules
/// </summary>
protected override IEnumerable<ICompression> BuiltInModules => CompressionModules.BuiltInCompressionModules;
/// <summary>
/// Instanciates a specific compression module, given the file extension and options
@@ -84,7 +87,7 @@ namespace Duplicati.Library.DynamicLoader
/// </summary>
/// <param name="key">The key to find commands for</param>
/// <returns>The supported commands or null if the key was not found</returns>
public IList<ICommandLineArgument> GetSupportedCommands(string key)
public IReadOnlyList<ICommandLineArgument> GetSupportedCommands(string key)
{
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException(nameof(key));
@@ -95,7 +98,7 @@ namespace Duplicati.Library.DynamicLoader
{
ICompression b;
if (m_interfaces.TryGetValue(key, out b) && b != null)
return b.SupportedCommands;
return GetSupportedCommandsCached(b).ToList();
else
return null;
}
@@ -124,7 +127,7 @@ namespace Duplicati.Library.DynamicLoader
/// </summary>
/// <param name="key">The compression module to find the commands for</param>
/// <returns>The supported commands or null if the key is not supported</returns>
public static IList<ICommandLineArgument> GetSupportedCommands(string key)
public static IReadOnlyList<ICommandLineArgument> GetSupportedCommands(string key)
{
return _compressionLoader.GetSupportedCommands(key);
}
@@ -5,11 +5,16 @@
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Logging\Duplicati.Library.Logging.csproj" />
<ProjectReference Include="..\Interface\Duplicati.Library.Interface.csproj" />
<ProjectReference Include="..\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\Localization\Duplicati.Library.Localization.csproj" />
<ProjectReference Include="..\Compression\Duplicati.Library.Compression.csproj" />
<ProjectReference Include="..\Backends\Duplicati.Library.Backends.csproj" />
<ProjectReference Include="..\Encryption\Duplicati.Library.Encryption.csproj" />
<ProjectReference Include="..\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj" />
<ProjectReference Include="..\AutoUpdater\Duplicati.Library.AutoUpdater.csproj" />
</ItemGroup>
<ItemGroup>
@@ -1,28 +1,31 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Duplicati.Library.AutoUpdater;
using Duplicati.Library.Interface;
namespace Duplicati.Library.DynamicLoader
{
@@ -30,7 +33,7 @@ namespace Duplicati.Library.DynamicLoader
/// This class supports dynamic loading of instances of a given interface
/// </summary>
/// <typeparam name="T">The interface that the class loads</typeparam>
internal abstract class DynamicLoader<T> where T : class
internal abstract class DynamicLoader<T> where T : class, IDynamicModule
{
/// <summary>
/// The tag used for logging
@@ -47,6 +50,11 @@ namespace Duplicati.Library.DynamicLoader
/// </summary>
protected Dictionary<string, T> m_interfaces;
/// <summary>
/// List of supported commands
/// </summary>
protected Dictionary<Type, IReadOnlyList<ICommandLineArgument>> m_supportedCommands = new();
/// <summary>
/// Function to extract the key value from the interface
/// </summary>
@@ -59,6 +67,11 @@ namespace Duplicati.Library.DynamicLoader
/// </summary>
protected abstract string[] Subfolders { get; }
/// <summary>
/// The list of statically included modules
/// </summary>
protected abstract IEnumerable<T> BuiltInModules { get; }
/// <summary>
/// Construct a new instance of the dynamic loader,
/// does not load anything
@@ -76,10 +89,14 @@ namespace Duplicati.Library.DynamicLoader
lock (m_lock)
if (m_interfaces == null)
{
Dictionary<string, T> interfaces = new Dictionary<string, T>();
//When loading, the subfolder matches are places last in the
var interfaces = new Dictionary<string, T>();
// When loading, inject the built-ins first, so they can be replaced by subfolder matches
foreach (T b in BuiltInModules)
interfaces[GetInterfaceKey(b)] = b;
// When loading, the subfolder matches are placed last in the
// resulting list, and thus applied last to the lookup,
// meaning that they can replace the stock versions
// meaning that they can replace the built-in versions
foreach (T b in FindInterfaceImplementors(Subfolders))
interfaces[GetInterfaceKey(b)] = b;
@@ -93,22 +110,34 @@ namespace Duplicati.Library.DynamicLoader
/// </summary>
/// <param name="additionalfolders">Any additional folders besides the assembly path to search in</param>
/// <returns>A list of instanciated classes which implements the interface</returns>
private List<T> FindInterfaceImplementors(string[] additionalfolders)
private IEnumerable<T> FindInterfaceImplementors(string[] additionalfolders)
{
List<T> interfaces = new List<T>();
var interfaces = new List<T>();
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
List<string> files = new List<string>();
files.AddRange(System.IO.Directory.GetFiles(path, "*.dll"));
// Search in these folders for modules
var root_paths = new[] {
Path.Combine(UpdaterManager.INSTALLATIONDIR, "modules"),
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) ?? string.Empty,
AutoUpdateSettings.AppName,
"modules"
),
Environment.GetEnvironmentVariable($"{AutoUpdateSettings.AppName}_MODULE_PATH")
}
.Where(x => !string.IsNullOrEmpty(x) && Directory.Exists(x));
//We can override with subfolders
if (additionalfolders != null)
foreach (string s in additionalfolders)
{
string subpath = System.IO.Path.Combine(path, s);
if (System.IO.Directory.Exists(subpath))
files.AddRange(System.IO.Directory.GetFiles(subpath, "*.dll"));
}
// In each folder we look, search only in the subfolders containing the modules
var files = new List<string>();
foreach (var path in root_paths)
{
if (additionalfolders != null)
foreach (string s in additionalfolders)
{
string subpath = System.IO.Path.Combine(path, s);
if (System.IO.Directory.Exists(subpath))
files.AddRange(System.IO.Directory.GetFiles(subpath, "*.dll"));
}
}
foreach (string s in files)
{
@@ -119,8 +148,8 @@ namespace Duplicati.Library.DynamicLoader
//Since the lookup dictionary applies the modules in the order returned
// and the subfolders are probed last, a module in the subfolder
// will take the place of a stock module, if both use same key
System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFile(s);
if (asm != System.Reflection.Assembly.GetExecutingAssembly())
Assembly asm = Assembly.LoadFile(s);
if (asm != Assembly.GetExecutingAssembly())
{
foreach (Type t in asm.GetExportedTypes())
try
@@ -143,8 +172,8 @@ namespace Duplicati.Library.DynamicLoader
}
}
}
catch(Exception ex)
{
catch (Exception ex)
{
ex = GetActualException(ex);
// Since this is locating the assemblies that have the proper interface, it isn't an error to not.
// This was loading the log with errors about additional DLL's that are not plugins and do not have manifests.
@@ -170,7 +199,7 @@ namespace Duplicati.Library.DynamicLoader
get
{
LoadInterfaces();
lock(m_lock)
lock (m_lock)
return new List<T>(m_interfaces.Values).ToArray();
}
}
@@ -188,5 +217,21 @@ namespace Duplicati.Library.DynamicLoader
}
}
/// <summary>
/// Returns the supported commands from the item, applying caching
/// </summary>
/// <param name="item">The item to get the supported commands for</param>
/// <returns>The list of supported commands</returns>
protected IEnumerable<ICommandLineArgument> GetSupportedCommandsCached(T item)
{
var type = item.GetType();
lock (m_lock)
{
if (m_supportedCommands.TryGetValue(type, out var commands))
return commands;
return m_supportedCommands[type] = item.SupportedCommands.ToList().AsReadOnly();
}
}
}
}
@@ -1,27 +1,28 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Duplicati.Library.Encryption;
using Duplicati.Library.Interface;
namespace Duplicati.Library.DynamicLoader
@@ -49,10 +50,12 @@ namespace Duplicati.Library.DynamicLoader
/// <summary>
/// Returns the subfolders searched for encryption modules
/// </summary>
protected override string[] Subfolders
{
get { return new string[] { "encryption" }; }
}
protected override string[] Subfolders => ["encryption"];
/// <summary>
/// The built-in modules
/// </summary>
protected override IEnumerable<IEncryption> BuiltInModules => EncryptionModules.BuiltInEncryptionModules;
/// <summary>
/// Instanciates a specific encryption module, given the file extension and options
@@ -82,7 +85,7 @@ namespace Duplicati.Library.DynamicLoader
/// </summary>
/// <param name="key">The key to find commands for</param>
/// <returns>The supported commands or null if the key was not found</returns>
public IList<ICommandLineArgument> GetSupportedCommands(string key)
public IReadOnlyList<ICommandLineArgument> GetSupportedCommands(string key)
{
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException(nameof(key));
@@ -93,7 +96,7 @@ namespace Duplicati.Library.DynamicLoader
{
IEncryption b;
if (m_interfaces.TryGetValue(key, out b) && b != null)
return b.SupportedCommands;
return GetSupportedCommandsCached(b).ToList();
else
return null;
}
@@ -122,7 +125,7 @@ namespace Duplicati.Library.DynamicLoader
/// </summary>
/// <param name="key">The encryption module to find the commands for</param>
/// <returns>The supported commands or null if the key is not supported</returns>
public static IList<ICommandLineArgument> GetSupportedCommands(string key)
public static IReadOnlyList<ICommandLineArgument> GetSupportedCommands(string key)
{
return _encryptionLoader.GetSupportedCommands(key);
}
@@ -1,28 +1,27 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using Duplicati.Library.Interface;
using Duplicati.Library.Modules.Builtin;
namespace Duplicati.Library.DynamicLoader
{
@@ -53,6 +52,11 @@ namespace Duplicati.Library.DynamicLoader
{
get { return new string[] { "modules" }; }
}
/// <summary>
/// The built-in modules
/// </summary>
protected override IEnumerable<IGenericModule> BuiltInModules => GenericModules.BuiltInGenericModules;
}
#region Public static API
+6 -2
View File
@@ -19,9 +19,8 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using Duplicati.Library.Backend;
using Duplicati.Library.Interface;
namespace Duplicati.Library.DynamicLoader
@@ -50,6 +49,11 @@ namespace Duplicati.Library.DynamicLoader
{
get { return new string[] { "webmodules" }; }
}
/// <summary>
/// The built-in modules
/// </summary>
override protected IEnumerable<IWebModule> BuiltInModules => WebModules.BuiltInWebModules;
}
#region Public static API
@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>Duplicati.Library.Encryption</RootNamespace>
</PropertyGroup>
<ItemGroup>
@@ -0,0 +1,36 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
using Duplicati.Library.Interface;
namespace Duplicati.Library.Encryption;
public static class EncryptionModules
{
/// <summary>
/// The list of all built-in encryption modules
/// </summary>
public static IReadOnlyList<IEncryption> BuiltInEncryptionModules => [
new AESEncryption(),
new GPGEncryption()
];
}
@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>Duplicati.Library.Interface</RootNamespace>
</PropertyGroup>
<ItemGroup>
+22 -27
View File
@@ -1,23 +1,23 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
@@ -36,12 +36,12 @@ namespace Duplicati.Library.Interface
/// The other constructor is used to do the actual work.
/// An instance is never reused.
/// </summary>
public interface IBackend : IDisposable
public interface IBackend : IDynamicModule, IDisposable
{
/// <summary>
/// The localized name to display for this backend
/// </summary>
string DisplayName { get;}
string DisplayName { get; }
/// <summary>
/// The protocol key, eg. ftp, http or ssh
@@ -75,11 +75,6 @@ namespace Duplicati.Library.Interface
/// <param name="remotename">The remote filename, relative to the URL</param>
void Delete(string remotename);
/// <summary>
/// Gets a list of supported commandline arguments
/// </summary>
IList<ICommandLineArgument> SupportedCommands { get; }
/// <summary>
/// A localized description of the backend, for display in the usage information
/// </summary>
+21 -28
View File
@@ -1,28 +1,26 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Duplicati.Library.Interface
{
@@ -143,7 +141,7 @@ namespace Duplicati.Library.Interface
/// The other constructor is used to do the actual work.
/// The input file may not exist or have zero length, in which case it should be created.
/// </summary>
public interface ICompression : IDisposable, IArchiveReader, IArchiveWriter
public interface ICompression : IDynamicModule, IDisposable, IArchiveReader, IArchiveWriter
{
/// <summary>
/// The total size of the archive.
@@ -164,10 +162,5 @@ namespace Duplicati.Library.Interface
/// A localized description of the compression module
/// </summary>
string Description { get; }
/// <summary>
/// Gets a list of supported commandline arguments
/// </summary>
IList<ICommandLineArgument> SupportedCommands { get; }
}
}
@@ -0,0 +1,35 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
namespace Duplicati.Library.Interface;
/// <summary>
/// Common interface for dynamic modules
/// </summary>
public interface IDynamicModule
{
/// <summary>
/// Gets a list of supported commandline arguments
/// </summary>
IList<ICommandLineArgument> SupportedCommands { get; }
}
+21 -27
View File
@@ -1,27 +1,26 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Duplicati.Library.Interface
@@ -37,7 +36,7 @@ namespace Duplicati.Library.Interface
/// The other constructor is used to do the actual work.
/// An instance can be used to encrypt or decrypt multiple files/streams.
/// </summary>
public interface IEncryption : IDisposable
public interface IEncryption : IDynamicModule, IDisposable
{
/// <summary>
/// Encrypts the contents of the inputfile, and saves the result as the outputfile.
@@ -96,11 +95,6 @@ namespace Duplicati.Library.Interface
/// </summary>
string Description { get; }
/// <summary>
/// Gets a list of supported commandline arguments
/// </summary>
IList<ICommandLineArgument> SupportedCommands { get; }
/// <summary>
/// Returns the size in bytes of the overhead that will be added to a file of the given size when encrypted
/// </summary>
+21 -28
View File
@@ -1,27 +1,25 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
namespace Duplicati.Library.Interface
{
@@ -36,7 +34,7 @@ namespace Duplicati.Library.Interface
/// All instances where the Configure method is called will be disposed,
/// if they implement the IDisposable interface as well.
/// </summary>
public interface IGenericModule
public interface IGenericModule : IDynamicModule
{
/// <summary>
/// The module key, used to activate or deactivate the module on the commandline
@@ -60,11 +58,6 @@ namespace Duplicati.Library.Interface
/// </summary>
bool LoadAsDefault { get; }
/// <summary>
/// Gets a list of supported commandline arguments
/// </summary>
IList<ICommandLineArgument> SupportedCommands { get; }
/// <summary>
/// This method is the interception where the module can interact with the execution environment and modify the settings.
/// </summary>
+3 -8
View File
@@ -24,7 +24,7 @@ using System.Collections.Generic;
namespace Duplicati.Library.Interface
{
public interface IWebModule
public interface IWebModule : IDynamicModule
{
/// <summary>
/// The module key, used to activate or deactivate the module on the commandline
@@ -40,19 +40,14 @@ namespace Duplicati.Library.Interface
/// A localized description of the module
/// </summary>
string Description { get; }
/// <summary>
/// Gets a list of supported commandline arguments
/// </summary>
IList<ICommandLineArgument> SupportedCommands { get; }
/// <summary>
/// Execute the specified command with the given options.
/// </summary>
/// <param name="options">The options to use</param>
/// <returns>A list of output values</returns>
IDictionary<string, string> Execute(IDictionary<string, string> options);
}
}
+46 -31
View File
@@ -123,7 +123,8 @@ namespace Duplicati.Library.Main
CheckAutoCompactInterval();
CheckAutoVacuumInterval();
return RunAction(new BackupResults(), ref inputsources, ref filter, (result) => {
return RunAction(new BackupResults(), ref inputsources, ref filter, (result) =>
{
using (var h = new Operation.BackupHandler(m_backend, m_options, result))
{
@@ -138,7 +139,8 @@ namespace Duplicati.Library.Main
public Library.Interface.IRestoreResults Restore(string[] paths, Library.Utility.IFilter filter = null)
{
return RunAction(new RestoreResults(), ref paths, ref filter, (result) => {
return RunAction(new RestoreResults(), ref paths, ref filter, (result) =>
{
new Operation.RestoreHandler(m_backend, m_options, result).Run(paths, filter);
Library.UsageReporter.Reporter.Report("RESTORE_FILECOUNT", result.RestoredFiles);
@@ -149,21 +151,24 @@ namespace Duplicati.Library.Main
public Duplicati.Library.Interface.IRestoreControlFilesResults RestoreControlFiles(IEnumerable<string> files = null, Library.Utility.IFilter filter = null)
{
return RunAction(new RestoreControlFilesResults(), ref filter, (result) => {
return RunAction(new RestoreControlFilesResults(), ref filter, (result) =>
{
new Operation.RestoreControlFilesHandler(m_backend, m_options, result).Run(files, filter);
});
}
public Duplicati.Library.Interface.IDeleteResults Delete()
{
return RunAction(new DeleteResults(), (result) => {
return RunAction(new DeleteResults(), (result) =>
{
new Operation.DeleteHandler(m_backend, m_options, result).Run();
});
}
public Duplicati.Library.Interface.IRepairResults Repair(Library.Utility.IFilter filter = null)
{
return RunAction(new RepairResults(), ref filter, (result) => {
return RunAction(new RepairResults(), ref filter, (result) =>
{
new Operation.RepairHandler(m_backend, m_options, result).Run(filter);
});
}
@@ -180,14 +185,16 @@ namespace Duplicati.Library.Main
public Duplicati.Library.Interface.IListResults List(IEnumerable<string> filterstrings, Library.Utility.IFilter filter)
{
return RunAction(new ListResults(), ref filter, (result) => {
return RunAction(new ListResults(), ref filter, (result) =>
{
new Operation.ListFilesHandler(m_backend, m_options, result).Run(filterstrings, filter);
});
}
public Duplicati.Library.Interface.IListResults ListControlFiles(IEnumerable<string> filterstrings, Library.Utility.IFilter filter)
{
return RunAction(new ListResults(), ref filter, (result) => {
return RunAction(new ListResults(), ref filter, (result) =>
{
new Operation.ListControlFilesHandler(m_backend, m_options, result).Run(filterstrings, filter);
});
}
@@ -254,7 +261,8 @@ namespace Duplicati.Library.Main
{
CheckAutoVacuumInterval();
return RunAction(new CompactResults(), (result) => {
return RunAction(new CompactResults(), (result) =>
{
new Operation.CompactHandler(m_backend, m_options, result).Run();
});
}
@@ -263,8 +271,9 @@ namespace Duplicati.Library.Main
{
var filelistfilter = Operation.RestoreHandler.FilterNumberedFilelist(m_options.Time, m_options.Version, singleTimeMatch: true);
return RunAction(new RecreateDatabaseResults(), ref filter, (result) => {
using(var h = new Operation.RecreateDatabaseHandler(m_backend, m_options, result))
return RunAction(new RecreateDatabaseResults(), ref filter, (result) =>
{
using (var h = new Operation.RecreateDatabaseHandler(m_backend, m_options, result))
h.RunUpdate(filter, filelistfilter);
});
}
@@ -273,7 +282,8 @@ namespace Duplicati.Library.Main
{
var t = new string[] { targetpath };
return RunAction(new CreateLogDatabaseResults(), ref t, (result) => {
return RunAction(new CreateLogDatabaseResults(), ref t, (result) =>
{
new Operation.CreateBugReportHandler(t[0], m_options, result).Run();
});
}
@@ -282,14 +292,16 @@ namespace Duplicati.Library.Main
{
var t = new string[] { baseVersion, targetVersion };
return RunAction(new ListChangesResults(), ref t, ref filter, (result) => {
return RunAction(new ListChangesResults(), ref t, ref filter, (result) =>
{
new Operation.ListChangesHandler(m_backend, m_options, result).Run(t[0], t[1], filterstrings, filter, callback);
});
}
public Duplicati.Library.Interface.IListAffectedResults ListAffected(List<string> args, Action<Duplicati.Library.Interface.IListAffectedResults> callback = null)
{
return RunAction(new ListAffectedResults(), (result) => {
return RunAction(new ListAffectedResults(), (result) =>
{
new Operation.ListAffected(m_options, result).Run(args, callback);
});
}
@@ -298,8 +310,9 @@ namespace Duplicati.Library.Main
{
if (!m_options.RawOptions.ContainsKey("full-remote-verification"))
m_options.RawOptions["full-remote-verification"] = "true";
return RunAction(new TestResults(), (result) => {
return RunAction(new TestResults(), (result) =>
{
new Operation.TestHandler(m_backend, m_options, result).Run(samples);
});
}
@@ -322,7 +335,8 @@ namespace Duplicati.Library.Main
public Library.Interface.ISystemInfoResults SystemInfo()
{
return RunAction(new SystemInfoResults(), result => {
return RunAction(new SystemInfoResults(), result =>
{
Operation.SystemInfoHandler.Run(result);
});
}
@@ -368,7 +382,7 @@ namespace Duplicati.Library.Main
)
.Select(x => x.Key)
);
/// Forward all messages from the email module to the message sink
var filtertag = Logging.Log.LogTagFromType<Modules.Builtin.SendMail>();
using (Logging.Log.StartScope(m_messageSink.WriteMessage, x => x.FilterTag.Contains(filtertag)))
@@ -383,7 +397,8 @@ namespace Duplicati.Library.Main
public Library.Interface.IVacuumResults Vacuum()
{
return RunAction(new VacuumResults(), result => {
return RunAction(new VacuumResults(), result =>
{
new Operation.VacuumHandler(m_options, result).Run();
});
}
@@ -429,14 +444,14 @@ namespace Duplicati.Library.Main
using (new ProcessController(m_options))
using (new Logging.Timer(LOGTAG, string.Format("Run{0}", result.MainOperation), string.Format("Running {0}", result.MainOperation)))
using(new CoCoL.IsolatedChannelScope())
using(m_options.ConcurrencyMaxThreads <= 0 ? null : new CoCoL.CappedThreadedThreadPool(m_options.ConcurrencyMaxThreads))
using (new CoCoL.IsolatedChannelScope())
using (m_options.ConcurrencyMaxThreads <= 0 ? null : new CoCoL.CappedThreadedThreadPool(m_options.ConcurrencyMaxThreads))
method(result);
if (result.EndTime.Ticks == 0)
result.EndTime = DateTime.UtcNow;
result.SetDatabase(null);
if(result is BasicResults r)
if (result is BasicResults r)
{
r.Interrupted = false;
}
@@ -611,7 +626,7 @@ namespace Duplicati.Library.Main
// Make the filter read-n-write able in the generic modules
var pristinefilter = string.Join(System.IO.Path.PathSeparator.ToString(), FilterExpression.Serialize(filter));
m_options.RawOptions["filter"] = pristinefilter;
// Store the URL connection options separately, as these should only be visible to modules implementing IConnectionModule
var conopts = new Dictionary<string, string>(m_options.RawOptions);
var qp = new Library.Utility.Uri(m_backend).QueryParameters;
@@ -792,11 +807,11 @@ namespace Duplicati.Library.Main
// Throw url-encoded options into the mix
//TODO: This can hide values if both commandline and url-parameters supply the same key
var ext = new Library.Utility.Uri(m_backend).QueryParameters;
foreach(var k in ext.AllKeys)
foreach (var k in ext.AllKeys)
ropts[k] = ext[k];
//Now run through all supported options, and look for deprecated options
foreach (IList<Library.Interface.ICommandLineArgument> l in new IList<Library.Interface.ICommandLineArgument>[] {
foreach (var l in new IEnumerable<ICommandLineArgument>[] {
m_options.SupportedCommands,
DynamicLoader.BackendLoader.GetSupportedCommands(m_backend),
m_options.NoEncryption ? null : DynamicLoader.EncryptionLoader.GetSupportedCommands(m_options.EncryptionModule),
@@ -872,12 +887,12 @@ namespace Duplicati.Library.Main
//TODO: Based on the action, see if all options are relevant
}
/// <summary>
/// Helper method that expands the users chosen source input paths,
/// and removes duplicate paths
/// </summary>
/// <returns>The expanded and filtered sources.</returns>
private string[] ExpandInputSources(string[] inputsources, IFilter filter)
/// <summary>
/// Helper method that expands the users chosen source input paths,
/// and removes duplicate paths
/// </summary>
/// <returns>The expanded and filtered sources.</returns>
private string[] ExpandInputSources(string[] inputsources, IFilter filter)
{
if (inputsources == null || inputsources.Length == 0)
throw new Duplicati.Library.Interface.UserInformationException(Strings.Controller.NoSourceFoldersError, "NoSourceFolders");
@@ -1061,7 +1076,7 @@ namespace Duplicati.Library.Main
else if (arg.Type == Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Flags)
{
bool validatedAllFlags = false;
var flags = (value ?? string.Empty).ToLowerInvariant().Split(new[] {","}, StringSplitOptions.None).Select(flag => flag.Trim()).Distinct();
var flags = (value ?? string.Empty).ToLowerInvariant().Split(new[] { "," }, StringSplitOptions.None).Select(flag => flag.Trim()).Distinct();
var validFlags = arg.ValidValues ?? new string[0];
foreach (var flag in flags)
@@ -8,24 +8,15 @@
<ItemGroup>
<ProjectReference Include="..\..\License\Duplicati.License.csproj" />
<ProjectReference Include="..\Compression\Duplicati.Library.Compression.csproj" />
<ProjectReference Include="..\Utility\Duplicati.Library.Utility.csproj">
</ProjectReference>
<ProjectReference Include="..\DynamicLoader\Duplicati.Library.DynamicLoader.csproj">
</ProjectReference>
<ProjectReference Include="..\Interface\Duplicati.Library.Interface.csproj">
</ProjectReference>
<ProjectReference Include="..\Logging\Duplicati.Library.Logging.csproj">
</ProjectReference>
<ProjectReference Include="..\Snapshots\Duplicati.Library.Snapshots.csproj">
</ProjectReference>
<ProjectReference Include="..\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\Localization\Duplicati.Library.Localization.csproj">
</ProjectReference>
<ProjectReference Include="..\UsageReporter\Duplicati.Library.UsageReporter.csproj">
</ProjectReference>
<ProjectReference Include="..\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj">
</ProjectReference>
<ProjectReference Include="..\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\DynamicLoader\Duplicati.Library.DynamicLoader.csproj" />
<ProjectReference Include="..\Interface\Duplicati.Library.Interface.csproj" />
<ProjectReference Include="..\Logging\Duplicati.Library.Logging.csproj" />
<ProjectReference Include="..\Snapshots\Duplicati.Library.Snapshots.csproj" />
<ProjectReference Include="..\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj" />
<ProjectReference Include="..\Localization\Duplicati.Library.Localization.csproj" />
<ProjectReference Include="..\UsageReporter\Duplicati.Library.UsageReporter.csproj" />
<ProjectReference Include="..\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj" />
</ItemGroup>
<ItemGroup>
@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>Duplicati.Library.Modules.Builtin</RootNamespace>
</PropertyGroup>
<ItemGroup>
@@ -0,0 +1,42 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
using Duplicati.Library.Interface;
namespace Duplicati.Library.Modules.Builtin;
public static class GenericModules
{
/// <summary>
/// The list of all built-in generic modules
/// </summary>
public static IReadOnlyList<IGenericModule> BuiltInGenericModules => [
new ConsolePasswordInput(),
new HttpOptions(),
new HyperVOptions(),
new MSSQLOptions(),
new RunScript(),
new SendHttpMessage(),
new SendJabberMessage(),
new SendMail(),
];
}
+17 -41
View File
@@ -18,48 +18,24 @@
<ItemGroup>
<ProjectReference Include="..\..\Duplicati.Library.RestAPI\Duplicati.Library.RestAPI.csproj" />
<ProjectReference Include="..\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj">
</ProjectReference>
<ProjectReference Include="..\CommandLine\CLI\Duplicati.CommandLine.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Backends\Duplicati.Library.Backends.csproj" />
<ProjectReference Include="..\Library\Backend\OAuthHelper\Duplicati.Library.OAuthHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Compression\Duplicati.Library.Compression.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Encryption\Duplicati.Library.Encryption.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Interface\Duplicati.Library.Interface.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Logging\Duplicati.Library.Logging.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Main\Duplicati.Library.Main.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Utility\Duplicati.Library.Utility.csproj">
</ProjectReference>
<ProjectReference Include="..\License\Duplicati.License.csproj">
</ProjectReference>
<ProjectReference Include="..\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj" />
<ProjectReference Include="..\CommandLine\CLI\Duplicati.CommandLine.csproj" />
<ProjectReference Include="..\Library\Backend\OAuthHelper\Duplicati.Library.OAuthHelper.csproj" />
<ProjectReference Include="..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj" />
<ProjectReference Include="..\Library\Encryption\Duplicati.Library.Encryption.csproj" />
<ProjectReference Include="..\Library\Logging\Duplicati.Library.Logging.csproj" />
<ProjectReference Include="..\Library\Main\Duplicati.Library.Main.csproj" />
<ProjectReference Include="..\Library\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\License\Duplicati.License.csproj" />
<ProjectReference Include="..\WebserverCore\Duplicati.WebserverCore.csproj" />
<ProjectReference Include="Duplicati.Server.Serialization\Duplicati.Server.Serialization.csproj">
</ProjectReference>
<ProjectReference Include="..\CommandLine\BackendTool\Duplicati.CommandLine.BackendTool.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Snapshots\Duplicati.Library.Snapshots.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Localization\Duplicati.Library.Localization.csproj">
</ProjectReference>
<ProjectReference Include="..\CommandLine\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\UsageReporter\Duplicati.Library.UsageReporter.csproj">
</ProjectReference>
<ProjectReference Include="..\Tools\Duplicati.Tools.csproj">
</ProjectReference>
<ProjectReference Include="Duplicati.Server.Serialization\Duplicati.Server.Serialization.csproj" />
<ProjectReference Include="..\CommandLine\BackendTool\Duplicati.CommandLine.BackendTool.csproj" />
<ProjectReference Include="..\Library\Snapshots\Duplicati.Library.Snapshots.csproj" />
<ProjectReference Include="..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj" />
<ProjectReference Include="..\Library\Localization\Duplicati.Library.Localization.csproj" />
<ProjectReference Include="..\CommandLine\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj" />
<ProjectReference Include="..\Library\UsageReporter\Duplicati.Library.UsageReporter.csproj" />
<ProjectReference Include="..\Tools\Duplicati.Tools.csproj" />
</ItemGroup>
<ItemGroup>
+19 -45
View File
@@ -14,51 +14,25 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj">
</ProjectReference>
<ProjectReference Include="..\CommandLine\CLI\Duplicati.CommandLine.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Backends\Duplicati.Library.Backends.csproj" />
<ProjectReference Include="..\Library\Backend\OAuthHelper\Duplicati.Library.OAuthHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Compression\Duplicati.Library.Compression.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Encryption\Duplicati.Library.Encryption.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Interface\Duplicati.Library.Interface.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Logging\Duplicati.Library.Logging.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Main\Duplicati.Library.Main.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Modules\Builtin\Duplicati.Library.Modules.Builtin.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Utility\Duplicati.Library.Utility.csproj">
</ProjectReference>
<ProjectReference Include="..\License\Duplicati.License.csproj">
</ProjectReference>
<ProjectReference Include="..\Server\Duplicati.Server.Serialization\Duplicati.Server.Serialization.csproj">
</ProjectReference>
<ProjectReference Include="..\Server\Duplicati.Server.csproj">
</ProjectReference>
<ProjectReference Include="..\CommandLine\BackendTool\Duplicati.CommandLine.BackendTool.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Snapshots\Duplicati.Library.Snapshots.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\Localization\Duplicati.Library.Localization.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj">
</ProjectReference>
<ProjectReference Include="..\CommandLine\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj">
</ProjectReference>
<ProjectReference Include="..\Library\UsageReporter\Duplicati.Library.UsageReporter.csproj">
</ProjectReference>
<ProjectReference Include="..\Tools\Duplicati.Tools.csproj">
</ProjectReference>
<ProjectReference Include="..\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj" />
<ProjectReference Include="..\CommandLine\CLI\Duplicati.CommandLine.csproj" />
<ProjectReference Include="..\Library\Backend\OAuthHelper\Duplicati.Library.OAuthHelper.csproj" />
<ProjectReference Include="..\Library\Compression\Duplicati.Library.Compression.csproj" />
<ProjectReference Include="..\Library\DynamicLoader\Duplicati.Library.DynamicLoader.csproj" />
<ProjectReference Include="..\Library\Logging\Duplicati.Library.Logging.csproj" />
<ProjectReference Include="..\Library\Main\Duplicati.Library.Main.csproj" />
<ProjectReference Include="..\Library\Utility\Duplicati.Library.Utility.csproj" />
<ProjectReference Include="..\License\Duplicati.License.csproj" />
<ProjectReference Include="..\Server\Duplicati.Server.Serialization\Duplicati.Server.Serialization.csproj" />
<ProjectReference Include="..\Server\Duplicati.Server.csproj" />
<ProjectReference Include="..\CommandLine\BackendTool\Duplicati.CommandLine.BackendTool.csproj" />
<ProjectReference Include="..\Library\Snapshots\Duplicati.Library.Snapshots.csproj" />
<ProjectReference Include="..\Library\SQLiteHelper\Duplicati.Library.SQLiteHelper.csproj" />
<ProjectReference Include="..\Library\Localization\Duplicati.Library.Localization.csproj" />
<ProjectReference Include="..\Library\AutoUpdater\Duplicati.Library.AutoUpdater.csproj" />
<ProjectReference Include="..\CommandLine\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj" />
<ProjectReference Include="..\Library\UsageReporter\Duplicati.Library.UsageReporter.csproj" />
<ProjectReference Include="..\Tools\Duplicati.Tools.csproj" />
</ItemGroup>
<ItemGroup>
+2 -1
View File
@@ -23,6 +23,7 @@ using Duplicati.Library.Interface;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -127,7 +128,7 @@ namespace Duplicati.UnitTest
get
{
if (m_backend == null)
try { return Duplicati.Library.DynamicLoader.BackendLoader.GetSupportedCommands(WrappedBackend + "://"); }
try { return Duplicati.Library.DynamicLoader.BackendLoader.GetSupportedCommands(WrappedBackend + "://").ToList(); }
catch { }
return m_backend.SupportedCommands;
+3 -3
View File
@@ -112,8 +112,8 @@ namespace Duplicati.UnitTest
get
{
if (m_backend == null)
try { return Duplicati.Library.DynamicLoader.BackendLoader.GetSupportedCommands(WrappedBackend + "://"); }
catch { }
try { return Duplicati.Library.DynamicLoader.BackendLoader.GetSupportedCommands(WrappedBackend + "://").ToList(); }
catch { }
return m_backend.SupportedCommands;
}
@@ -131,7 +131,7 @@ namespace Duplicati.UnitTest
{
if (m_backend != null)
try { m_backend.Dispose(); }
finally { m_backend = null; }
finally { m_backend = null; }
}
#endregion
}
@@ -7,8 +7,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj">
</ProjectReference>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\BackendTester\Duplicati.CommandLine.BackendTester.csproj" />
</ItemGroup>
<ItemGroup>
@@ -7,8 +7,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\BackendTool\Duplicati.CommandLine.BackendTool.csproj">
</ProjectReference>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\BackendTool\Duplicati.CommandLine.BackendTool.csproj" />
</ItemGroup>
<ItemGroup>
@@ -7,8 +7,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\ConfigurationImporter\Duplicati.CommandLine.ConfigurationImporter.csproj">
</ProjectReference>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\ConfigurationImporter\Duplicati.CommandLine.ConfigurationImporter.csproj" />
</ItemGroup>
<ItemGroup>
@@ -7,8 +7,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj">
</ProjectReference>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\RecoveryTool\Duplicati.CommandLine.RecoveryTool.csproj" />
</ItemGroup>
<ItemGroup>
@@ -7,8 +7,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\CLI\Duplicati.CommandLine.csproj">
</ProjectReference>
<ProjectReference Include="..\..\..\Duplicati\CommandLine\CLI\Duplicati.CommandLine.csproj" />
</ItemGroup>
<ItemGroup>