diff --git a/src/NzbDrone.Core/DiskSpace/DiskSpaceService.cs b/src/NzbDrone.Core/DiskSpace/DiskSpaceService.cs index b57dac3e75..5f79a3e93e 100644 --- a/src/NzbDrone.Core/DiskSpace/DiskSpaceService.cs +++ b/src/NzbDrone.Core/DiskSpace/DiskSpaceService.cs @@ -69,14 +69,19 @@ private IEnumerable GetDiskSpace(IEnumerable paths) try { - var freeSpace = _diskProvider.GetAvailableSpace(path).Value; - var totalSpace = _diskProvider.GetTotalSize(path).Value; + var freeSpace = _diskProvider.GetAvailableSpace(path); + var totalSpace = _diskProvider.GetTotalSize(path); + + if (!freeSpace.HasValue || !totalSpace.HasValue) + { + continue; + } diskSpace = new DiskSpace { Path = path, - FreeSpace = freeSpace, - TotalSpace = totalSpace + FreeSpace = freeSpace.Value, + TotalSpace = totalSpace.Value }; diskSpace.Label = _diskProvider.GetVolumeLabel(path); diff --git a/src/NzbDrone.Mono/DiskProvider.cs b/src/NzbDrone.Mono/DiskProvider.cs index cfbaa98c48..3a2d2e8b28 100644 --- a/src/NzbDrone.Mono/DiskProvider.cs +++ b/src/NzbDrone.Mono/DiskProvider.cs @@ -24,7 +24,15 @@ public class DiskProvider : DiskProviderBase try { - return GetDriveInfoLinux(path).AvailableFreeSpace; + var driveInfo = GetDriveInfoLinux(path); + + if (driveInfo == null) + { + Logger.Trace("Unable to get free space for '{0}', unable to find suitable drive", path); + return null; + } + + return driveInfo.AvailableFreeSpace; } catch (InvalidOperationException e) { @@ -132,7 +140,7 @@ private DriveInfo GetDriveInfoLinux(string path) drives.Where(drive => drive.IsReady && path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase)) .OrderByDescending(drive => drive.Name.Length) - .First(); + .FirstOrDefault(); } } }