New: Refresh cache for tracked queue on movie add

pull/10069/head
Bogdan 7 months ago
parent c8b409ed0b
commit 8a5c0ffd18

@ -28,6 +28,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
}
public class TrackedDownloadService : ITrackedDownloadService,
IHandle<MovieAddedEvent>,
IHandle<MoviesDeletedEvent>
{
private readonly IParsingService _parsingService;
@ -250,11 +251,28 @@ namespace NzbDrone.Core.Download.TrackedDownloads
}
}
public void Handle(MovieAddedEvent message)
{
var cachedItems = _cache.Values
.Where(t =>
t.RemoteMovie?.Movie == null ||
message.Movie?.TmdbId == t.RemoteMovie.Movie.TmdbId)
.ToList();
if (cachedItems.Any())
{
cachedItems.ForEach(UpdateCachedItem);
_eventAggregator.PublishEvent(new TrackedDownloadRefreshedEvent(GetTrackedDownloads()));
}
}
public void Handle(MoviesDeletedEvent message)
{
var cachedItems = _cache.Values.Where(t =>
var cachedItems = _cache.Values
.Where(t =>
t.RemoteMovie?.Movie != null &&
message.Movies.Any(m => m.Id == t.RemoteMovie.Movie.Id))
message.Movies.Any(m => m.Id == t.RemoteMovie.Movie.Id || m.TmdbId == t.RemoteMovie.Movie.TmdbId))
.ToList();
if (cachedItems.Any())

Loading…
Cancel
Save