Updated the common library, using the Nuget Posix package
This commit is contained in:
@@ -13,5 +13,6 @@
|
||||
<PackageReference Include="AlphaVSS" Version="2.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
<PackageReference Include="Mono.Posix" Version="7.1.0-final.1.21458.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -22,14 +22,14 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Mono.Unix.Native;
|
||||
|
||||
namespace UnixSupport
|
||||
namespace Duplicati.Library.Common.IO
|
||||
{
|
||||
public static class File
|
||||
public static class PosixFile
|
||||
{
|
||||
|
||||
private static readonly bool SUPPORTS_LLISTXATTR;
|
||||
|
||||
static File ()
|
||||
static PosixFile ()
|
||||
{
|
||||
bool works = false;
|
||||
try
|
||||
@@ -108,12 +108,12 @@ namespace Duplicati.Library.Common.IO
|
||||
|
||||
public void CreateSymlink(string symlinkfile, string target, bool asDir)
|
||||
{
|
||||
UnixSupport.File.CreateSymlink(symlinkfile, target);
|
||||
PosixFile.CreateSymlink(symlinkfile, target);
|
||||
}
|
||||
|
||||
public string GetSymlinkTarget(string path)
|
||||
{
|
||||
return UnixSupport.File.GetSymlinkTarget(NormalizePath(path));
|
||||
return PosixFile.GetSymlinkTarget(NormalizePath(path));
|
||||
}
|
||||
|
||||
public string PathGetDirectoryName(string path)
|
||||
@@ -181,12 +181,12 @@ namespace Duplicati.Library.Common.IO
|
||||
var f = NormalizePath(file);
|
||||
var dict = new Dictionary<string, string>();
|
||||
|
||||
var n = UnixSupport.File.GetExtendedAttributes(f, isSymlink, followSymlink);
|
||||
var n = PosixFile.GetExtendedAttributes(f, isSymlink, followSymlink);
|
||||
if (n != null)
|
||||
foreach(var x in n)
|
||||
dict["unix-ext:" + x.Key] = Convert.ToBase64String(x.Value);
|
||||
|
||||
var fse = UnixSupport.File.GetUserGroupAndPermissions(f);
|
||||
var fse = PosixFile.GetUserGroupAndPermissions(f);
|
||||
dict["unix:uid-gid-perm"] = string.Format("{0}-{1}-{2}", fse.UID, fse.GID, fse.Permissions);
|
||||
if (fse.OwnerName != null)
|
||||
{
|
||||
@@ -208,7 +208,7 @@ namespace Duplicati.Library.Common.IO
|
||||
var f = NormalizePath(file);
|
||||
|
||||
foreach(var x in data.Where(x => x.Key.StartsWith("unix-ext:", StringComparison.Ordinal)).Select(x => new KeyValuePair<string, byte[]>(x.Key.Substring("unix-ext:".Length), Convert.FromBase64String(x.Value))))
|
||||
UnixSupport.File.SetExtendedAttribute(f, x.Key, x.Value);
|
||||
PosixFile.SetExtendedAttribute(f, x.Key, x.Value);
|
||||
|
||||
if (restorePermissions && data.ContainsKey("unix:uid-gid-perm"))
|
||||
{
|
||||
@@ -222,14 +222,14 @@ namespace Duplicati.Library.Common.IO
|
||||
if (long.TryParse(parts[0], out uid) && long.TryParse(parts[1], out gid) && long.TryParse(parts[2], out perm))
|
||||
{
|
||||
if (data.ContainsKey("unix:owner-name"))
|
||||
try { uid = UnixSupport.File.GetUserID(data["unix:owner-name"]); }
|
||||
try { uid = PosixFile.GetUserID(data["unix:owner-name"]); }
|
||||
catch { }
|
||||
|
||||
if (data.ContainsKey("unix:group-name"))
|
||||
try { gid = UnixSupport.File.GetGroupID(data["unix:group-name"]); }
|
||||
try { gid = PosixFile.GetGroupID(data["unix:group-name"]); }
|
||||
catch { }
|
||||
|
||||
UnixSupport.File.SetUserGroupAndPermissions(f, uid, gid, perm);
|
||||
PosixFile.SetUserGroupAndPermissions(f, uid, gid, perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,22 +237,22 @@ namespace Duplicati.Library.Common.IO
|
||||
|
||||
private System.Security.AccessControl.FileSystemSecurity GetAccessControlDir(string path)
|
||||
{
|
||||
return System.IO.Directory.GetAccessControl(AddExtendedDevicePathPrefix(path));
|
||||
return new DirectoryInfo(AddExtendedDevicePathPrefix(path)).GetAccessControl();
|
||||
}
|
||||
|
||||
private System.Security.AccessControl.FileSystemSecurity GetAccessControlFile(string path)
|
||||
{
|
||||
return System.IO.File.GetAccessControl(AddExtendedDevicePathPrefix(path));
|
||||
return new FileInfo(AddExtendedDevicePathPrefix(path)).GetAccessControl();
|
||||
}
|
||||
|
||||
private void SetAccessControlFile(string path, FileSecurity rules)
|
||||
{
|
||||
System.IO.File.SetAccessControl(AddExtendedDevicePathPrefix(path), rules);
|
||||
new FileInfo(AddExtendedDevicePathPrefix(path)).SetAccessControl(rules);
|
||||
}
|
||||
|
||||
private void SetAccessControlDir(string path, DirectorySecurity rules)
|
||||
{
|
||||
System.IO.Directory.SetAccessControl(AddExtendedDevicePathPrefix(path), rules);
|
||||
new DirectoryInfo(AddExtendedDevicePathPrefix(path)).SetAccessControl(rules);
|
||||
}
|
||||
|
||||
#region ISystemIO implementation
|
||||
|
||||
@@ -299,14 +299,7 @@ namespace Duplicati.Library.Common.IO
|
||||
|
||||
public static IVssBackupComponents CreateVssBackupComponents()
|
||||
{
|
||||
// Substitute for calling VssUtils.LoadImplementation(), as we have the dlls outside the GAC
|
||||
var assemblyLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
if (assemblyLocation == null)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
//Here we don't need a custom Path.Combine: we need unconditional access to alphaFS
|
||||
var alphadll = Path.Combine(assemblyLocation, "alphavss", VssUtils.GetPlatformSpecificAssemblyShortName() + ".dll");
|
||||
var vss = (IVssImplementation)System.Reflection.Assembly.LoadFile(alphadll).CreateInstance("Alphaleonis.Win32.Vss.VssImplementation");
|
||||
var vss = VssFactoryProvider.Default.GetVssFactory();
|
||||
if (vss == null)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
This project is not really 3rd party.
|
||||
|
||||
It was created solely for use with Duplicati, but it depends on the Mono.Posix.dll file, which is not found on the common Windows developer platform. By creating this mini project, it is possible to reference the functions from Mono.Posix during a Windows build without having access to the Mono.Posix.dll. As this dll is never invoked on Windows, it should have no interest to the Windows developer.
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<ReleaseVersion>1.0</ReleaseVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Posix" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.Posix" Version="7.1.0-final.1.21458.1" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user