From f776aae2c06f5d33c0a66cddd30ffc0a1c3cdd17 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 19 Oct 2014 17:47:23 -0700 Subject: [PATCH] Fixed: Mono returning a drive with an empty path causing disk space check to fail --- src/NzbDrone.Mono/DiskProvider.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Mono/DiskProvider.cs b/src/NzbDrone.Mono/DiskProvider.cs index 8be9ad768..0eac87104 100644 --- a/src/NzbDrone.Mono/DiskProvider.cs +++ b/src/NzbDrone.Mono/DiskProvider.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using Mono.Unix.Native; using NLog; +using NzbDrone.Common; using NzbDrone.Common.Disk; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Instrumentation; @@ -34,9 +35,9 @@ namespace NzbDrone.Mono return driveInfo.AvailableFreeSpace; } - catch (InvalidOperationException e) + catch (InvalidOperationException ex) { - Logger.ErrorException("Couldn't get free space for " + path, e); + Logger.ErrorException("Couldn't get free space for " + path, ex); } return null; @@ -144,10 +145,11 @@ namespace NzbDrone.Mono var drives = DriveInfo.GetDrives(); return - drives.Where(drive => - drive.IsReady && path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase)) - .OrderByDescending(drive => drive.Name.Length) - .FirstOrDefault(); + drives.Where(drive => drive.IsReady && + drive.Name.IsNotNullOrWhiteSpace() && + path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase)) + .OrderByDescending(drive => drive.Name.Length) + .FirstOrDefault(); } } }