mirror of
https://github.com/Readarr/Readarr
synced 2026-05-09 05:21:41 +02:00
Fixed: Imports triggered through API not being marked as imported/removed from client
Fixes #258 (cherry picked from commit 382bcbcbeddcf04d5bc361744b6b57ca3c2c54e6)
This commit is contained in:
parent
fc8b6014ec
commit
842f80d567
2 changed files with 11 additions and 6 deletions
|
|
@ -18,6 +18,7 @@ public interface ICompletedDownloadService
|
||||||
{
|
{
|
||||||
void Check(TrackedDownload trackedDownload);
|
void Check(TrackedDownload trackedDownload);
|
||||||
void Import(TrackedDownload trackedDownload);
|
void Import(TrackedDownload trackedDownload);
|
||||||
|
bool VerifyImport(TrackedDownload trackedDownload, List<ImportResult> importResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CompletedDownloadService : ICompletedDownloadService
|
public class CompletedDownloadService : ICompletedDownloadService
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Download.TrackedDownloads;
|
using NzbDrone.Core.Download.TrackedDownloads;
|
||||||
using NzbDrone.Core.MediaFiles.BookImport;
|
using NzbDrone.Core.MediaFiles.BookImport;
|
||||||
using NzbDrone.Core.MediaFiles.Commands;
|
using NzbDrone.Core.MediaFiles.Commands;
|
||||||
|
|
@ -16,16 +17,19 @@ public class DownloadedBooksCommandService : IExecute<DownloadedBooksScanCommand
|
||||||
private readonly IDownloadedBooksImportService _downloadedTracksImportService;
|
private readonly IDownloadedBooksImportService _downloadedTracksImportService;
|
||||||
private readonly ITrackedDownloadService _trackedDownloadService;
|
private readonly ITrackedDownloadService _trackedDownloadService;
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
private readonly ICompletedDownloadService _completedDownloadService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public DownloadedBooksCommandService(IDownloadedBooksImportService downloadedTracksImportService,
|
public DownloadedBooksCommandService(IDownloadedBooksImportService downloadedTracksImportService,
|
||||||
ITrackedDownloadService trackedDownloadService,
|
ITrackedDownloadService trackedDownloadService,
|
||||||
IDiskProvider diskProvider,
|
IDiskProvider diskProvider,
|
||||||
|
ICompletedDownloadService completedDownloadService,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_downloadedTracksImportService = downloadedTracksImportService;
|
_downloadedTracksImportService = downloadedTracksImportService;
|
||||||
_trackedDownloadService = trackedDownloadService;
|
_trackedDownloadService = trackedDownloadService;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
|
_completedDownloadService = completedDownloadService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,14 +49,14 @@ private List<ImportResult> ProcessPath(DownloadedBooksScanCommand message)
|
||||||
{
|
{
|
||||||
_logger.Debug("External directory scan request for known download {0}. [{1}]", message.DownloadClientId, message.Path);
|
_logger.Debug("External directory scan request for known download {0}. [{1}]", message.DownloadClientId, message.Path);
|
||||||
|
|
||||||
return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode, trackedDownload.RemoteBook.Author, trackedDownload.DownloadItem);
|
var importResults = _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode, trackedDownload.RemoteBook.Author, trackedDownload.DownloadItem);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Warn("External directory scan request for unknown download {0}, attempting normal import. [{1}]", message.DownloadClientId, message.Path);
|
|
||||||
|
|
||||||
return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode);
|
_completedDownloadService.VerifyImport(trackedDownload, importResults);
|
||||||
|
|
||||||
|
return importResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.Warn("External directory scan request for unknown download {0}, attempting normal import. [{1}]", message.DownloadClientId, message.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode);
|
return _downloadedTracksImportService.ProcessPath(message.Path, message.ImportMode);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue