Fixed: UI loading when series or root folder path is for wrong OS
This commit is contained in:
parent
d581de00c9
commit
5f72178445
|
@ -169,6 +169,11 @@ namespace NzbDrone.Common.Extensions
|
||||||
|
|
||||||
public static bool ContainsInvalidPathChars(this string text)
|
public static bool ContainsInvalidPathChars(this string text)
|
||||||
{
|
{
|
||||||
|
if (text.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("text");
|
||||||
|
}
|
||||||
|
|
||||||
return text.IndexOfAny(Path.GetInvalidPathChars()) >= 0;
|
return text.IndexOfAny(Path.GetInvalidPathChars()) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,10 @@ using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.HealthCheck.Checks;
|
using NzbDrone.Core.HealthCheck.Checks;
|
||||||
using NzbDrone.Core.Localization;
|
using NzbDrone.Core.Localization;
|
||||||
|
using NzbDrone.Core.RootFolders;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||||
{
|
{
|
||||||
|
@ -22,7 +24,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||||
.Returns("Some Warning Message");
|
.Returns("Some Warning Message");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenMissingRootFolder()
|
private void GivenMissingRootFolder(string rootFolderPath)
|
||||||
{
|
{
|
||||||
var series = Builder<Series>.CreateListOfSize(1)
|
var series = Builder<Series>.CreateListOfSize(1)
|
||||||
.Build()
|
.Build()
|
||||||
|
@ -32,9 +34,9 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||||
.Setup(s => s.GetAllSeriesPaths())
|
.Setup(s => s.GetAllSeriesPaths())
|
||||||
.Returns(series.ToDictionary(s => s.Id, s => s.Path));
|
.Returns(series.ToDictionary(s => s.Id, s => s.Path));
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IRootFolderService>()
|
||||||
.Setup(s => s.GetParentFolder(series.First().Path))
|
.Setup(s => s.GetBestRootFolderPath(It.IsAny<string>()))
|
||||||
.Returns(@"C:\TV");
|
.Returns(rootFolderPath);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.FolderExists(It.IsAny<string>()))
|
.Setup(s => s.FolderExists(It.IsAny<string>()))
|
||||||
|
@ -54,7 +56,25 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_error_if_series_parent_is_missing()
|
public void should_return_error_if_series_parent_is_missing()
|
||||||
{
|
{
|
||||||
GivenMissingRootFolder();
|
GivenMissingRootFolder(@"C:\TV".AsOsAgnostic());
|
||||||
|
|
||||||
|
Subject.Check().ShouldBeError();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_error_if_series_path_is_for_posix_os()
|
||||||
|
{
|
||||||
|
WindowsOnly();
|
||||||
|
GivenMissingRootFolder("/mnt/tv");
|
||||||
|
|
||||||
|
Subject.Check().ShouldBeError();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_error_if_series_path_is_for_windows()
|
||||||
|
{
|
||||||
|
PosixOnly();
|
||||||
|
GivenMissingRootFolder(@"C:\TV");
|
||||||
|
|
||||||
Subject.Check().ShouldBeError();
|
Subject.Check().ShouldBeError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
namespace NzbDrone.Core.DiskSpace
|
namespace NzbDrone.Core.DiskSpace
|
||||||
|
@ -43,7 +44,7 @@ namespace NzbDrone.Core.DiskSpace
|
||||||
private IEnumerable<string> GetSeriesRootPaths()
|
private IEnumerable<string> GetSeriesRootPaths()
|
||||||
{
|
{
|
||||||
return _seriesService.GetAllSeriesPaths()
|
return _seriesService.GetAllSeriesPaths()
|
||||||
.Where(s => _diskProvider.FolderExists(s.Value))
|
.Where(s => s.Value.IsPathValid(PathValidationType.CurrentOs) && _diskProvider.FolderExists(s.Value))
|
||||||
.Select(s => _diskProvider.GetPathRoot(s.Value))
|
.Select(s => _diskProvider.GetPathRoot(s.Value))
|
||||||
.Distinct();
|
.Distinct();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Localization;
|
using NzbDrone.Core.Localization;
|
||||||
using NzbDrone.Core.MediaFiles.Events;
|
using NzbDrone.Core.MediaFiles.Events;
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
|
@ -32,7 +33,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
||||||
.Select(s => _rootFolderService.GetBestRootFolderPath(s.Value))
|
.Select(s => _rootFolderService.GetBestRootFolderPath(s.Value))
|
||||||
.Distinct();
|
.Distinct();
|
||||||
|
|
||||||
var missingRootFolders = rootFolders.Where(s => !_diskProvider.FolderExists(s))
|
var missingRootFolders = rootFolders.Where(s => !s.IsPathValid(PathValidationType.CurrentOs) || !_diskProvider.FolderExists(s))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (missingRootFolders.Any())
|
if (missingRootFolders.Any())
|
||||||
|
|
|
@ -190,10 +190,12 @@ namespace NzbDrone.Core.RootFolders
|
||||||
|
|
||||||
if (possibleRootFolder == null)
|
if (possibleRootFolder == null)
|
||||||
{
|
{
|
||||||
return _diskProvider.GetParentFolder(path);
|
var osPath = new OsPath(path);
|
||||||
|
|
||||||
|
return osPath.Directory.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return possibleRootFolder.Path;
|
return possibleRootFolder?.Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetDetails(RootFolder rootFolder, Dictionary<int, string> seriesPaths, bool timeout)
|
private void GetDetails(RootFolder rootFolder, Dictionary<int, string> seriesPaths, bool timeout)
|
||||||
|
|
Loading…
Reference in New Issue