1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-29 23:12:39 +01:00

Fixed: Persist Indexer Flags for automatic imports

Revert "Fixed: Persist Indexer Flags when manual importing from queue"

This reverts commit 217611d716.
This commit is contained in:
Bogdan 2024-08-01 08:15:36 +03:00 committed by GitHub
parent 217611d716
commit 4ff83f9efc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 11 deletions

View File

@ -7,6 +7,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Core.CustomFormats;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
@ -29,6 +30,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
private readonly IAggregationService _aggregationService;
private readonly IDiskProvider _diskProvider;
private readonly IDetectSample _detectSample;
private readonly ITrackedDownloadService _trackedDownloadService;
private readonly ICustomFormatCalculationService _formatCalculator;
private readonly Logger _logger;
@ -37,6 +39,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
IAggregationService aggregationService,
IDiskProvider diskProvider,
IDetectSample detectSample,
ITrackedDownloadService trackedDownloadService,
ICustomFormatCalculationService formatCalculator,
Logger logger)
{
@ -45,6 +48,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
_aggregationService = aggregationService;
_diskProvider = diskProvider;
_detectSample = detectSample;
_trackedDownloadService = trackedDownloadService;
_formatCalculator = formatCalculator;
_logger = logger;
}
@ -145,6 +149,16 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
}
else
{
if (downloadClientItem?.DownloadId.IsNotNullOrWhiteSpace() == true)
{
var trackedDownload = _trackedDownloadService.Find(downloadClientItem.DownloadId);
if (trackedDownload?.RemoteEpisode?.Release?.IndexerFlags != null)
{
localEpisode.IndexerFlags = trackedDownload.RemoteEpisode.Release.IndexerFlags;
}
}
localEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(localEpisode);
localEpisode.CustomFormatScore = localEpisode.Series.QualityProfile?.Value.CalculateCustomFormatScore(localEpisode.CustomFormats) ?? 0;

View File

@ -215,7 +215,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
{
DownloadClientItem downloadClientItem = null;
Series series = null;
TrackedDownload trackedDownload = null;
var directoryInfo = new DirectoryInfo(baseFolder);
@ -237,7 +236,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
if (downloadId.IsNotNullOrWhiteSpace())
{
trackedDownload = _trackedDownloadService.Find(downloadId);
var trackedDownload = _trackedDownloadService.Find(downloadId);
downloadClientItem = trackedDownload.DownloadItem;
if (series == null)
@ -273,11 +272,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
var seriesFiles = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder).ToList());
var decisions = _importDecisionMaker.GetImportDecisions(seriesFiles, series, downloadClientItem, folderInfo, SceneSource(series, baseFolder), filterExistingFiles);
foreach (var decision in decisions)
{
decision.LocalEpisode.IndexerFlags = trackedDownload?.RemoteEpisode?.Release?.IndexerFlags ?? 0;
}
return decisions.Select(decision => MapItem(decision, rootFolder, downloadId, directoryInfo.Name)).ToList();
}
@ -337,10 +331,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
if (importDecisions.Any())
{
var importDecision = importDecisions.First();
importDecision.LocalEpisode.IndexerFlags = trackedDownload?.RemoteEpisode?.Release?.IndexerFlags ?? 0;
return MapItem(importDecision, rootFolder, downloadId, null);
return MapItem(importDecisions.First(), rootFolder, downloadId, null);
}
}
catch (Exception ex)