From bc395860bb2ba31e6bcf2c026dd4c66d2cacb829 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 3 Mar 2020 16:54:12 -0800 Subject: [PATCH] Fixed: Inaccessible path leading to import process being aborted before processing all items --- .../Download/DownloadProcessingService.cs | 26 ++++++++++++++----- .../DownloadedBooksImportService.cs | 8 ++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/Download/DownloadProcessingService.cs b/src/NzbDrone.Core/Download/DownloadProcessingService.cs index aaa8079e2..14b04a385 100644 --- a/src/NzbDrone.Core/Download/DownloadProcessingService.cs +++ b/src/NzbDrone.Core/Download/DownloadProcessingService.cs @@ -1,5 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; +using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Messaging.Commands; @@ -14,18 +16,21 @@ namespace NzbDrone.Core.Download private readonly IFailedDownloadService _failedDownloadService; private readonly ITrackedDownloadService _trackedDownloadService; private readonly IEventAggregator _eventAggregator; + private readonly ILogger _logger; public DownloadProcessingService(IConfigService configService, ICompletedDownloadService completedDownloadService, IFailedDownloadService failedDownloadService, ITrackedDownloadService trackedDownloadService, - IEventAggregator eventAggregator) + IEventAggregator eventAggregator, + ILogger logger) { _configService = configService; _completedDownloadService = completedDownloadService; _failedDownloadService = failedDownloadService; _trackedDownloadService = trackedDownloadService; _eventAggregator = eventAggregator; + _logger = logger; } private void RemoveCompletedDownloads(List trackedDownloads) @@ -43,14 +48,21 @@ namespace NzbDrone.Core.Download foreach (var trackedDownload in trackedDownloads) { - if (trackedDownload.State == TrackedDownloadState.DownloadFailedPending) + try { - _failedDownloadService.ProcessFailed(trackedDownload); - } + if (trackedDownload.State == TrackedDownloadState.DownloadFailedPending) + { + _failedDownloadService.ProcessFailed(trackedDownload); + } - if (enableCompletedDownloadHandling && trackedDownload.State == TrackedDownloadState.ImportPending) + if (enableCompletedDownloadHandling && trackedDownload.State == TrackedDownloadState.ImportPending) + { + _completedDownloadService.Import(trackedDownload); + } + } + catch (Exception e) { - _completedDownloadService.Import(trackedDownload); + _logger.Debug(e, "Failed to process download: {0}", trackedDownload.DownloadItem.Title); } } diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedBooksImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedBooksImportService.cs index 07355e39e..189601044 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedBooksImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedBooksImportService.cs @@ -78,6 +78,8 @@ namespace NzbDrone.Core.MediaFiles public List ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Author author = null, DownloadClientItem downloadClientItem = null) { + _logger.Debug("Processing path: {0}", path); + if (_diskProvider.FolderExists(path)) { var directoryInfo = _diskProvider.GetDirectoryInfo(path); @@ -335,6 +337,12 @@ namespace NzbDrone.Core.MediaFiles var mounts = _diskProvider.GetMounts(); var mount = mounts.FirstOrDefault(m => m.RootDirectory == Path.GetPathRoot(path)); + if (mount == null) + { + _logger.Error("Import failed, path does not exist or is not accessible by Lidarr: {0}. Unable to find a volume mounted for the path. If you're using a mapped network drive see the FAQ for more info", path); + return; + } + if (mount.DriveType == DriveType.Network) { _logger.Error("Import failed, path does not exist or is not accessible by Readarr: {0}. It's recommended to avoid mapped network drives when running as a Windows service. See the FAQ for more info", path);