mirror of
https://github.com/lidarr/Lidarr
synced 2025-03-16 08:39:36 +00:00
Changed code to avoid duplicates making their way into the TrackedDownload cache.
This commit is contained in:
parent
b72c9b338c
commit
231128e01c
1 changed files with 6 additions and 4 deletions
|
@ -105,7 +105,7 @@ namespace NzbDrone.Core.Download
|
||||||
var downloadClients = _downloadClientProvider.GetDownloadClients();
|
var downloadClients = _downloadClientProvider.GetDownloadClients();
|
||||||
|
|
||||||
var oldTrackedDownloads = GetTrackedDownloads().ToDictionary(v => v.TrackingId);
|
var oldTrackedDownloads = GetTrackedDownloads().ToDictionary(v => v.TrackingId);
|
||||||
var newTrackedDownloads = new List<TrackedDownload>();
|
var newTrackedDownloads = new Dictionary<String, TrackedDownload>();
|
||||||
|
|
||||||
var stateChanged = false;
|
var stateChanged = false;
|
||||||
|
|
||||||
|
@ -117,6 +117,8 @@ namespace NzbDrone.Core.Download
|
||||||
var trackingId = String.Format("{0}-{1}", downloadClient.Definition.Id, downloadItem.DownloadClientId);
|
var trackingId = String.Format("{0}-{1}", downloadClient.Definition.Id, downloadItem.DownloadClientId);
|
||||||
TrackedDownload trackedDownload;
|
TrackedDownload trackedDownload;
|
||||||
|
|
||||||
|
if (newTrackedDownloads.ContainsKey(trackingId)) continue;
|
||||||
|
|
||||||
if (!oldTrackedDownloads.TryGetValue(trackingId, out trackedDownload))
|
if (!oldTrackedDownloads.TryGetValue(trackingId, out trackedDownload))
|
||||||
{
|
{
|
||||||
trackedDownload = new TrackedDownload
|
trackedDownload = new TrackedDownload
|
||||||
|
@ -133,11 +135,11 @@ namespace NzbDrone.Core.Download
|
||||||
|
|
||||||
trackedDownload.DownloadItem = downloadItem;
|
trackedDownload.DownloadItem = downloadItem;
|
||||||
|
|
||||||
newTrackedDownloads.Add(trackedDownload);
|
newTrackedDownloads[trackingId] = trackedDownload;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var downloadItem in oldTrackedDownloads.Values.Except(newTrackedDownloads))
|
foreach (var downloadItem in oldTrackedDownloads.Values.Where(v => !newTrackedDownloads.ContainsKey(v.TrackingId)))
|
||||||
{
|
{
|
||||||
if (downloadItem.State != TrackedDownloadState.Removed)
|
if (downloadItem.State != TrackedDownloadState.Removed)
|
||||||
{
|
{
|
||||||
|
@ -150,7 +152,7 @@ namespace NzbDrone.Core.Download
|
||||||
_logger.Trace("Stopped tracking download: {0}: {1}", downloadItem.TrackingId, downloadItem.DownloadItem.Title);
|
_logger.Trace("Stopped tracking download: {0}: {1}", downloadItem.TrackingId, downloadItem.DownloadItem.Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
_trackedDownloadCache.Set("tracked", newTrackedDownloads.ToArray());
|
_trackedDownloadCache.Set("tracked", newTrackedDownloads.Values.ToArray());
|
||||||
|
|
||||||
return stateChanged;
|
return stateChanged;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue