1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-23 00:07:07 +00:00

New: Refresh cache for tracked queue on series add

This commit is contained in:
Bogdan 2024-05-30 00:25:51 +03:00 committed by Mark McDowall
parent e07eb05e8b
commit ea54ade9bf

View file

@ -28,6 +28,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
public class TrackedDownloadService : ITrackedDownloadService,
IHandle<EpisodeInfoRefreshedEvent>,
IHandle<SeriesAddedEvent>,
IHandle<SeriesDeletedEvent>
{
private readonly IParsingService _parsingService;
@ -278,12 +279,29 @@ namespace NzbDrone.Core.Download.TrackedDownloads
}
}
public void Handle(SeriesAddedEvent message)
{
var cachedItems = _cache.Values
.Where(t =>
t.RemoteEpisode?.Series == null ||
message.Series?.TvdbId == t.RemoteEpisode.Series.TvdbId)
.ToList();
if (cachedItems.Any())
{
cachedItems.ForEach(UpdateCachedItem);
_eventAggregator.PublishEvent(new TrackedDownloadRefreshedEvent(GetTrackedDownloads()));
}
}
public void Handle(SeriesDeletedEvent message)
{
var cachedItems = _cache.Values.Where(t =>
t.RemoteEpisode?.Series != null &&
message.Series.Any(s => s.Id == t.RemoteEpisode.Series.Id))
.ToList();
var cachedItems = _cache.Values
.Where(t =>
t.RemoteEpisode?.Series != null &&
message.Series.Any(s => s.Id == t.RemoteEpisode.Series.Id || s.TvdbId == t.RemoteEpisode.Series.TvdbId))
.ToList();
if (cachedItems.Any())
{