1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

more linux fixes

This commit is contained in:
kay.one 2013-07-25 22:55:19 -07:00
parent c2b4eadc47
commit 67661c6893
3 changed files with 26 additions and 12 deletions

View File

@ -1,4 +1,5 @@
using System.IO;
using System.Diagnostics;
using System.IO;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
@ -30,7 +31,7 @@ public void ApplicationPath_should_not_be_empty()
[Test]
public void IsProduction_should_return_false_when_run_within_nunit()
{
RuntimeInfo.IsProduction.Should().BeFalse();
RuntimeInfo.IsProduction.Should().BeFalse("Process name is " + Process.GetCurrentProcess().ProcessName);
}
}
}

View File

@ -101,7 +101,7 @@ public virtual bool FolderExists(string path)
Ensure.That(() => path).IsValidPath();
return Directory.Exists(path);
}
public virtual bool FolderExists(string path, bool caseSensitive)
{
if (caseSensitive)
@ -394,16 +394,28 @@ public virtual string GetPathRoot(string 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);
try
{
directorySecurity.AddAccessRule(accessRule);
directoryInfo.SetAccessControl(directorySecurity);
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);
}
catch (Exception e)
{
Logger.WarnException(string.Format("Couldn't set permission for {0}. account:{1} rights:{2} accessControlType:{3}", filename, account, rights, controlType), e);
throw;
}
}
public bool IsParent(string parent, string subfolder)
@ -420,7 +432,7 @@ public bool IsParent(string parent, string subfolder)
{
return true;
}
diSubfolder = diSubfolder.Parent;
}

View File

@ -11,7 +11,8 @@ public static string AsOsAgnostic(this string path)
{
if (path.Length > 2 && path[1] == ':')
{
path = path.Replace(':', Path.DirectorySeparatorChar);
path = path.Replace(":", "");
path = Path.DirectorySeparatorChar + path;
}
path = path.Replace("\\", Path.DirectorySeparatorChar.ToString());
}