Fixed exception in MountCheck if RootDirectory cannot be found.

pull/1910/head
Taloth Saldono 8 years ago
parent db15949704
commit 95c81f8905

@ -86,7 +86,7 @@ namespace NzbDrone.Common.Test
{ {
first.AsOsAgnostic().PathEquals(second.AsOsAgnostic()).Should().BeFalse(); first.AsOsAgnostic().PathEquals(second.AsOsAgnostic()).Should().BeFalse();
} }
[Test] [Test]
public void should_return_false_when_not_a_child() public void should_return_false_when_not_a_child()
{ {
@ -113,6 +113,7 @@ namespace NzbDrone.Common.Test
[TestCase(@"C:\Test\", @"C:\Test\mydir")] [TestCase(@"C:\Test\", @"C:\Test\mydir")]
[TestCase(@"C:\Test\", @"C:\Test\mydir\")] [TestCase(@"C:\Test\", @"C:\Test\mydir\")]
[TestCase(@"C:\Test", @"C:\Test\30.Rock.S01E01.Pilot.avi")] [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) public void path_should_be_parent(string parentPath, string childPath)
{ {
parentPath.AsOsAgnostic().IsParentPath(childPath.AsOsAgnostic()).Should().BeTrue(); parentPath.AsOsAgnostic().IsParentPath(childPath.AsOsAgnostic()).Should().BeTrue();

@ -80,11 +80,11 @@ namespace NzbDrone.Common.Extensions
public static bool IsParentPath(this string parentPath, string childPath) public static bool IsParentPath(this string parentPath, string childPath)
{ {
if (parentPath != "/") if (parentPath != "/" && !parentPath.EndsWith(":\\"))
{ {
parentPath = parentPath.TrimEnd(Path.DirectorySeparatorChar); parentPath = parentPath.TrimEnd(Path.DirectorySeparatorChar);
} }
if (childPath != "/") if (childPath != "/" && !parentPath.EndsWith(":\\"))
{ {
childPath = childPath.TrimEnd(Path.DirectorySeparatorChar); childPath = childPath.TrimEnd(Path.DirectorySeparatorChar);
} }
@ -276,4 +276,4 @@ namespace NzbDrone.Common.Extensions
return Path.Combine(appFolderInfo.StartUpFolder, NLOG_CONFIG_FILE); return Path.Combine(appFolderInfo.StartUpFolder, NLOG_CONFIG_FILE);
} }
} }
} }

@ -21,8 +21,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
// Not best for optimization but due to possible symlinks and junctions, we get mounts based on series path so internals can handle mount resolution. // 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() var mounts = _seriesService.GetAllSeries()
.Select(series => _diskProvider.GetMount(series.Path)) .Select(series => _diskProvider.GetMount(series.Path))
.Where(m => m != null && m.MountOptions != null && m.MountOptions.IsReadOnly)
.DistinctBy(m => m.RootDirectory) .DistinctBy(m => m.RootDirectory)
.Where(m => m.MountOptions != null && m.MountOptions.IsReadOnly)
.ToList(); .ToList();
if (mounts.Any()) if (mounts.Any())

Loading…
Cancel
Save