mirror of
https://github.com/Radarr/Radarr.git
synced 2024-07-15 00:57:36 +02:00
Fixed: UI loading when movie or root folder path is for wrong OS
(cherry picked from commit 5f7217844533907d7fc6287a48efb31987736c4c)
This commit is contained in:
parent
bd49a4ee8b
commit
b8f06eb97d
@ -170,6 +170,11 @@ public static bool IsPathValid(this string path, PathValidationType validationTy
|
||||
|
||||
public static bool ContainsInvalidPathChars(this string text)
|
||||
{
|
||||
if (text.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new ArgumentNullException("text");
|
||||
}
|
||||
|
||||
return text.IndexOfAny(Path.GetInvalidPathChars()) >= 0;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,9 @@
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Localization;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
@ -22,7 +24,7 @@ public void Setup()
|
||||
.Returns("Some Warning Message");
|
||||
}
|
||||
|
||||
private void GivenMissingRootFolder()
|
||||
private void GivenMissingRootFolder(string rootFolderPath)
|
||||
{
|
||||
var movies = Builder<Movie>.CreateListOfSize(1)
|
||||
.Build()
|
||||
@ -32,9 +34,9 @@ private void GivenMissingRootFolder()
|
||||
.Setup(s => s.AllMoviePaths())
|
||||
.Returns(movies.ToDictionary(x => x.Id, x => x.Path));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetParentFolder(movies.First().Path))
|
||||
.Returns(@"C:\Movies");
|
||||
Mocker.GetMock<IRootFolderService>()
|
||||
.Setup(s => s.GetBestRootFolderPath(It.IsAny<string>(), null))
|
||||
.Returns(rootFolderPath);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.FolderExists(It.IsAny<string>()))
|
||||
@ -54,7 +56,25 @@ public void should_not_return_error_when_no_movie()
|
||||
[Test]
|
||||
public void should_return_error_if_movie_parent_is_missing()
|
||||
{
|
||||
GivenMissingRootFolder();
|
||||
GivenMissingRootFolder(@"C:\Movies".AsOsAgnostic());
|
||||
|
||||
Subject.Check().ShouldBeError();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_error_if_series_path_is_for_posix_os()
|
||||
{
|
||||
WindowsOnly();
|
||||
GivenMissingRootFolder("/mnt/movies");
|
||||
|
||||
Subject.Check().ShouldBeError();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_error_if_series_path_is_for_windows()
|
||||
{
|
||||
PosixOnly();
|
||||
GivenMissingRootFolder(@"C:\Movies");
|
||||
|
||||
Subject.Check().ShouldBeError();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
||||
namespace NzbDrone.Core.DiskSpace
|
||||
@ -43,7 +44,7 @@ public List<DiskSpace> GetFreeSpace()
|
||||
private IEnumerable<string> GetMoviesRootPaths()
|
||||
{
|
||||
return _movieService.AllMoviePaths()
|
||||
.Where(s => _diskProvider.FolderExists(s.Value))
|
||||
.Where(s => s.Value.IsPathValid(PathValidationType.CurrentOs) && _diskProvider.FolderExists(s.Value))
|
||||
.Select(s => _diskProvider.GetPathRoot(s.Value))
|
||||
.Distinct();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Localization;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Movies;
|
||||
@ -32,7 +33,7 @@ public override HealthCheck Check()
|
||||
.Select(s => _rootFolderService.GetBestRootFolderPath(s.Value))
|
||||
.Distinct();
|
||||
|
||||
var missingRootFolders = rootFolders.Where(s => !_diskProvider.FolderExists(s))
|
||||
var missingRootFolders = rootFolders.Where(s => !s.IsPathValid(PathValidationType.CurrentOs) || !_diskProvider.FolderExists(s))
|
||||
.ToList();
|
||||
|
||||
if (missingRootFolders.Any())
|
||||
|
@ -188,10 +188,12 @@ public string GetBestRootFolderPath(string path, List<RootFolder> rootFolders =
|
||||
|
||||
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> moviePaths, bool timeout)
|
||||
|
Loading…
Reference in New Issue
Block a user