Fixed: Inaccessible path leading to import process being aborted before processing all items

Fixes #3598
This commit is contained in:
Mark McDowall 2020-03-03 16:54:12 -08:00
parent 3ad396a9c2
commit 15d84046db
2 changed files with 29 additions and 8 deletions

View File

@ -1,5 +1,7 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
@ -14,18 +16,21 @@ namespace NzbDrone.Core.Download
private readonly IFailedDownloadService _failedDownloadService; private readonly IFailedDownloadService _failedDownloadService;
private readonly ITrackedDownloadService _trackedDownloadService; private readonly ITrackedDownloadService _trackedDownloadService;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly ILogger _logger;
public DownloadProcessingService(IConfigService configService, public DownloadProcessingService(IConfigService configService,
ICompletedDownloadService completedDownloadService, ICompletedDownloadService completedDownloadService,
IFailedDownloadService failedDownloadService, IFailedDownloadService failedDownloadService,
ITrackedDownloadService trackedDownloadService, ITrackedDownloadService trackedDownloadService,
IEventAggregator eventAggregator) IEventAggregator eventAggregator,
ILogger logger)
{ {
_configService = configService; _configService = configService;
_completedDownloadService = completedDownloadService; _completedDownloadService = completedDownloadService;
_failedDownloadService = failedDownloadService; _failedDownloadService = failedDownloadService;
_trackedDownloadService = trackedDownloadService; _trackedDownloadService = trackedDownloadService;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_logger = logger;
} }
private void RemoveCompletedDownloads(List<TrackedDownload> trackedDownloads) private void RemoveCompletedDownloads(List<TrackedDownload> trackedDownloads)
@ -43,15 +48,23 @@ namespace NzbDrone.Core.Download
foreach (var trackedDownload in trackedDownloads) foreach (var trackedDownload in trackedDownloads)
{ {
if (trackedDownload.State == TrackedDownloadState.FailedPending) try
{ {
_failedDownloadService.ProcessFailed(trackedDownload); if (trackedDownload.State == TrackedDownloadState.FailedPending)
{
_failedDownloadService.ProcessFailed(trackedDownload);
}
if (enableCompletedDownloadHandling && trackedDownload.State == TrackedDownloadState.ImportPending)
{
_completedDownloadService.Import(trackedDownload);
}
}
catch (Exception e)
{
_logger.Debug(e, "Failed to process download: {0}", trackedDownload.DownloadItem.Title);
} }
if (enableCompletedDownloadHandling && trackedDownload.State == TrackedDownloadState.ImportPending)
{
_completedDownloadService.Import(trackedDownload);
}
} }
if (enableCompletedDownloadHandling && _configService.RemoveCompletedDownloads) if (enableCompletedDownloadHandling && _configService.RemoveCompletedDownloads)

View File

@ -75,6 +75,8 @@ namespace NzbDrone.Core.MediaFiles
public List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Series series = null, DownloadClientItem downloadClientItem = null) public List<ImportResult> ProcessPath(string path, ImportMode importMode = ImportMode.Auto, Series series = null, DownloadClientItem downloadClientItem = null)
{ {
_logger.Debug("Processing path: {0}", path);
if (_diskProvider.FolderExists(path)) if (_diskProvider.FolderExists(path))
{ {
var directoryInfo = new DirectoryInfo(path); var directoryInfo = new DirectoryInfo(path);
@ -279,6 +281,12 @@ namespace NzbDrone.Core.MediaFiles
var mounts = _diskProvider.GetMounts(); var mounts = _diskProvider.GetMounts();
var mount = mounts.FirstOrDefault(m => m.RootDirectory == Path.GetPathRoot(path)); 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 Sonarr: {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) if (mount.DriveType == DriveType.Network)
{ {
_logger.Error("Import failed, path does not exist or is not accessible by Sonarr: {0}. It's recommended to avoid mapped network drives when running as a Windows service. See the FAQ for more info", path); _logger.Error("Import failed, path does not exist or is not accessible by Sonarr: {0}. It's recommended to avoid mapped network drives when running as a Windows service. See the FAQ for more info", path);