Mountpoint is not supported for disk image backup

This commit is contained in:
Carl Johnsen
2026-02-06 12:16:23 +01:00
parent 2c8c9b5082
commit 0bba2fb986
2 changed files with 16 additions and 10 deletions
@@ -156,22 +156,27 @@ namespace Duplicati.Library.Main.Operation
foreach (var url in entry)
{
var sanitizedUrl = Library.Utility.Utility.GetUrlWithoutCredentials(url);
var m = Regex.Match(url, @"^@(?<mountpoint>[^|]+)\|(?<url>.+)$", RegexOptions.IgnoreCase);
var m = Regex.Match(url, @"^@(?<mountpoint>[^|]+\|)*(?<url>.+)$", RegexOptions.IgnoreCase);
if (m.Success)
{
var mountpoint = m.Groups["mountpoint"].Value;
if (mountpoint.Any(x => Path.GetInvalidPathChars().Contains(x)))
throw new UserInformationException(string.Format("The mountpoint \"{0}\" contains invalid characters", mountpoint), "InvalidMountpoint");
if (!Path.IsPathRooted(mountpoint))
throw new UserInformationException(string.Format("The mountpoint \"{0}\" is not a valid rooted mountpoint", mountpoint), "InvalidMountpoint");
if (!string.IsNullOrEmpty(mountpoint))
{
if (mountpoint.Any(x => Path.GetInvalidPathChars().Contains(x)))
throw new UserInformationException(string.Format("The mountpoint \"{0}\" contains invalid characters", mountpoint), "InvalidMountpoint");
if (!Path.IsPathRooted(mountpoint))
throw new UserInformationException(string.Format("The mountpoint \"{0}\" is not a valid rooted mountpoint", mountpoint), "InvalidMountpoint");
mountpoint = Path.GetFullPath(mountpoint);
}
var backendurl = m.Groups["url"].Value;
ISourceProvider provider;
try
{
provider = await SourceProviderLoader.GetSourceProvider(backendurl, Path.GetFullPath(mountpoint), options.RawOptions, cancellationToken).ConfigureAwait(false);
// TODO double check that all providers that require a mountpoint throws correctly when mountpoint is not set.
provider = await SourceProviderLoader.GetSourceProvider(backendurl, mountpoint, options.RawOptions, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
@@ -181,6 +186,7 @@ namespace Duplicati.Library.Main.Operation
continue;
}
Console.WriteLine(ex.StackTrace);
throw new UserInformationException($"Failed to load source provider for \"{sanitizedUrl}\": {ex.Message}", "SourceProviderFailed", ex);
}
+4 -4
View File
@@ -16,7 +16,6 @@ namespace Duplicati.Proprietary.DiskImage;
public sealed class SourceProvider : ISourceProviderModule, IDisposable
{
private readonly string _devicePath;
private readonly string _mountPoint;
private IRawDisk? _disk;
private bool _disposed;
@@ -25,17 +24,18 @@ public sealed class SourceProvider : ISourceProviderModule, IDisposable
public SourceProvider()
{
_devicePath = null!;
_mountPoint = null!;
}
public SourceProvider(string url, string mountPoint, Dictionary<string, string?> options)
{
_mountPoint = mountPoint;
if (!string.IsNullOrEmpty(mountPoint))
throw new UserInformationException("Mount point option is not supported for DiskImage provider. The entire disk will be mounted/treated as root.", "MountPointNotSupported");
var uri = new Library.Utility.Uri(url);
_devicePath = uri.HostAndPath;
}
public string MountedPath => _mountPoint;
public string MountedPath => $"root{System.IO.Path.DirectorySeparatorChar}";
public string DisplayName => Strings.ProviderDisplayName;