From 8228f1134530b58c55f3d3efe542da0cbc2a4f2d Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 12 Feb 2023 19:50:15 -0800 Subject: [PATCH] Fixed: Prevent getting disk space from returning no information when it partially fails (cherry picked from commit 2c65e4fa41418157d0d27b34c3bab80158cff219) --- src/NzbDrone.Mono/Disk/DiskProvider.cs | 34 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Mono/Disk/DiskProvider.cs b/src/NzbDrone.Mono/Disk/DiskProvider.cs index b447662ec..26b3d5151 100644 --- a/src/NzbDrone.Mono/Disk/DiskProvider.cs +++ b/src/NzbDrone.Mono/Disk/DiskProvider.cs @@ -184,14 +184,32 @@ namespace NzbDrone.Mono.Disk protected override List GetAllMounts() { - return _procMountProvider.GetMounts() - .Concat(GetDriveInfoMounts() - .Select(d => new DriveInfoMount(d, FindDriveType.Find(d.DriveFormat))) - .Where(d => d.DriveType == DriveType.Fixed || - d.DriveType == DriveType.Network || - d.DriveType == DriveType.Removable)) - .DistinctBy(v => v.RootDirectory) - .ToList(); + var mounts = new List(); + + try + { + mounts.AddRange(_procMountProvider.GetMounts()); + } + catch (Exception e) + { + _logger.Warn(e, $"Unable to get mounts: {e.Message}"); + } + + try + { + mounts.AddRange(GetDriveInfoMounts() + .Select(d => new DriveInfoMount(d, FindDriveType.Find(d.DriveFormat))) + .Where(d => d.DriveType == DriveType.Fixed || + d.DriveType == DriveType.Network || + d.DriveType == DriveType.Removable)); + } + catch (Exception e) + { + _logger.Warn(e, $"Unable to get drive mounts: {e.Message}"); + } + + return mounts.DistinctBy(v => v.RootDirectory) + .ToList(); } protected override bool IsSpecialMount(IMount mount)