From 95c81f890581d5be9b67b1bcc03624b2341e6ff0 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 10 May 2017 22:48:36 +0200 Subject: [PATCH] Fixed exception in MountCheck if RootDirectory cannot be found. --- src/NzbDrone.Common.Test/PathExtensionFixture.cs | 3 ++- src/NzbDrone.Common/Extensions/PathExtensions.cs | 6 +++--- src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Common.Test/PathExtensionFixture.cs b/src/NzbDrone.Common.Test/PathExtensionFixture.cs index e3e7fb34a..ec5451029 100644 --- a/src/NzbDrone.Common.Test/PathExtensionFixture.cs +++ b/src/NzbDrone.Common.Test/PathExtensionFixture.cs @@ -86,7 +86,7 @@ public void paths_should_not_be_equal(string first, string second) { first.AsOsAgnostic().PathEquals(second.AsOsAgnostic()).Should().BeFalse(); } - + [Test] public void should_return_false_when_not_a_child() { @@ -113,6 +113,7 @@ public void should_return_true_when_folder_is_parent_of_a_file() [TestCase(@"C:\Test\", @"C:\Test\mydir")] [TestCase(@"C:\Test\", @"C:\Test\mydir\")] [TestCase(@"C:\Test", @"C:\Test\30.Rock.S01E01.Pilot.avi")] + [TestCase(@"C:\", @"C:\Test\30.Rock.S01E01.Pilot.avi")] public void path_should_be_parent(string parentPath, string childPath) { parentPath.AsOsAgnostic().IsParentPath(childPath.AsOsAgnostic()).Should().BeTrue(); diff --git a/src/NzbDrone.Common/Extensions/PathExtensions.cs b/src/NzbDrone.Common/Extensions/PathExtensions.cs index e03f0a594..7576d454a 100644 --- a/src/NzbDrone.Common/Extensions/PathExtensions.cs +++ b/src/NzbDrone.Common/Extensions/PathExtensions.cs @@ -80,11 +80,11 @@ public static string GetParentPath(this string childPath) public static bool IsParentPath(this string parentPath, string childPath) { - if (parentPath != "/") + if (parentPath != "/" && !parentPath.EndsWith(":\\")) { parentPath = parentPath.TrimEnd(Path.DirectorySeparatorChar); } - if (childPath != "/") + if (childPath != "/" && !parentPath.EndsWith(":\\")) { childPath = childPath.TrimEnd(Path.DirectorySeparatorChar); } @@ -276,4 +276,4 @@ public static string GetNlogConfigPath(this IAppFolderInfo appFolderInfo) return Path.Combine(appFolderInfo.StartUpFolder, NLOG_CONFIG_FILE); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs index 263ae2927..6e79be2d6 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/MountCheck.cs @@ -21,8 +21,8 @@ public override HealthCheck Check() // Not best for optimization but due to possible symlinks and junctions, we get mounts based on series path so internals can handle mount resolution. var mounts = _seriesService.GetAllSeries() .Select(series => _diskProvider.GetMount(series.Path)) + .Where(m => m != null && m.MountOptions != null && m.MountOptions.IsReadOnly) .DistinctBy(m => m.RootDirectory) - .Where(m => m.MountOptions != null && m.MountOptions.IsReadOnly) .ToList(); if (mounts.Any())