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

pull/3113/head
Mark McDowall 8 years ago
parent 1a61796092
commit d3890bd712

@ -1,5 +1,7 @@
using NUnit.Framework; using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnsureThat; using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.Extensions;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
namespace NzbDrone.Common.Test.EnsureTest namespace NzbDrone.Common.Test.EnsureTest
@ -22,5 +24,18 @@ namespace NzbDrone.Common.Test.EnsureTest
MonoOnly(); MonoOnly();
Ensure.That(path, () => path).IsValidPath(); 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());
}
} }
} }

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NzbDrone.Common.EnsureThat; using NzbDrone.Common.EnsureThat;
@ -174,6 +175,21 @@ namespace NzbDrone.Common.Extensions
return Path.Combine(GetProperCapitalization(dirInfo), fileName); 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) public static string GetAppDataPath(this IAppFolderInfo appFolderInfo)
{ {
return appFolderInfo.AppDataFolder; return appFolderInfo.AppDataFolder;

@ -2,6 +2,7 @@
using System.IO; using System.IO;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Update; using NzbDrone.Core.Update;
@ -33,6 +34,13 @@ namespace NzbDrone.Core.HealthCheck.Checks
if ((OsInfo.IsWindows || _configFileProvider.UpdateAutomatically) && if ((OsInfo.IsWindows || _configFileProvider.UpdateAutomatically) &&
_configFileProvider.UpdateMechanism == UpdateMechanism.BuiltIn) _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)) if (!_diskProvider.FolderWritable(startupFolder))
{ {
return new HealthCheck(GetType(), HealthCheckResult.Error, return new HealthCheck(GetType(), HealthCheckResult.Error,

Loading…
Cancel
Save