|
|
@ -2,6 +2,7 @@
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
using System.Security.AccessControl;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common.EnsureThat;
|
|
|
|
using NzbDrone.Common.EnsureThat;
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
@ -33,6 +34,7 @@ namespace NzbDrone.Common
|
|
|
|
void FolderSetLastWriteTimeUtc(string path, DateTime dateTime);
|
|
|
|
void FolderSetLastWriteTimeUtc(string path, DateTime dateTime);
|
|
|
|
bool IsFileLocked(FileInfo file);
|
|
|
|
bool IsFileLocked(FileInfo file);
|
|
|
|
string GetPathRoot(string path);
|
|
|
|
string GetPathRoot(string path);
|
|
|
|
|
|
|
|
void SetPermissions(string filename, string account, FileSystemRights Rights, AccessControlType ControlType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class DiskProvider : IDiskProvider
|
|
|
|
public class DiskProvider : IDiskProvider
|
|
|
@ -83,7 +85,6 @@ namespace NzbDrone.Common
|
|
|
|
return new FileInfo(path).LastWriteTimeUtc;
|
|
|
|
return new FileInfo(path).LastWriteTimeUtc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void EnsureFolder(string path)
|
|
|
|
public virtual void EnsureFolder(string path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!FolderExists(path))
|
|
|
|
if (!FolderExists(path))
|
|
|
@ -366,5 +367,19 @@ namespace NzbDrone.Common
|
|
|
|
|
|
|
|
|
|
|
|
return Path.GetPathRoot(path);
|
|
|
|
return Path.GetPathRoot(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void SetPermissions(string filename, string account, FileSystemRights rights, AccessControlType controlType)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var directoryInfo = new DirectoryInfo(filename);
|
|
|
|
|
|
|
|
var directorySecurity = directoryInfo.GetAccessControl();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var accessRule = new FileSystemAccessRule(account, rights,
|
|
|
|
|
|
|
|
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
|
|
|
|
|
|
|
|
PropagationFlags.None, controlType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
directorySecurity.AddAccessRule(accessRule);
|
|
|
|
|
|
|
|
directoryInfo.SetAccessControl(directorySecurity);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|