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

New: Health check warning for macOS when running from App Translocation folder

This commit is contained in:
Mark McDowall 2016-11-02 11:09:29 -07:00
parent 1a61796092
commit d3890bd712
3 changed files with 40 additions and 1 deletions

View File

@ -1,5 +1,7 @@
using NUnit.Framework;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.Extensions;
using NzbDrone.Test.Common;
namespace NzbDrone.Common.Test.EnsureTest
@ -22,5 +24,18 @@ public void EnsureLinuxPath(string path)
MonoOnly();
Ensure.That(path, () => path).IsValidPath();
}
[Test]
public void GetAncestorFolders_should_return_all_ancestors_in_path()
{
var path = @"C:\Test\TV\Series Title".AsOsAgnostic();
var result = path.GetAncestorFolders();
result.Count.Should().Be(4);
result[0].Should().Be(@"C:\".AsOsAgnostic());
result[1].Should().Be(@"Test".AsOsAgnostic());
result[2].Should().Be(@"TV".AsOsAgnostic());
result[3].Should().Be(@"Series Title".AsOsAgnostic());
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using NzbDrone.Common.EnsureThat;
@ -174,6 +175,21 @@ public static string GetActualCasing(this string path)
return Path.Combine(GetProperCapitalization(dirInfo), fileName);
}
public static List<string> GetAncestorFolders(this string path)
{
var directory = new DirectoryInfo(path);
var directories = new List<string>();
while (directory != null)
{
directories.Insert(0, directory.Name);
directory = directory.Parent;
}
return directories;
}
public static string GetAppDataPath(this IAppFolderInfo appFolderInfo)
{
return appFolderInfo.AppDataFolder;

View File

@ -2,6 +2,7 @@
using System.IO;
using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Update;
@ -33,6 +34,13 @@ public override HealthCheck Check()
if ((OsInfo.IsWindows || _configFileProvider.UpdateAutomatically) &&
_configFileProvider.UpdateMechanism == UpdateMechanism.BuiltIn)
{
if (OsInfo.IsOsx && startupFolder.GetAncestorFolders().Contains("AppTranslocation"))
{
return new HealthCheck(GetType(), HealthCheckResult.Error,
string.Format("Cannot install update because startup folder '{0}' is in an App Translocation folder.", startupFolder),
"Cannot install update because startup folder is in an App Translocation folder.");
}
if (!_diskProvider.FolderWritable(startupFolder))
{
return new HealthCheck(GetType(), HealthCheckResult.Error,