Fixed: Refresh queue items for changed series

This commit is contained in:
Bogdan 2024-05-03 23:28:17 +03:00
parent c81ae65461
commit 789cbd5496
2 changed files with 37 additions and 8 deletions

View File

@ -28,7 +28,8 @@ namespace NzbDrone.Core.Download.TrackedDownloads
public class TrackedDownloadService : ITrackedDownloadService,
IHandle<EpisodeInfoRefreshedEvent>,
IHandle<SeriesDeletedEvent>
IHandle<SeriesDeletedEvent>,
IHandle<SeriesEditedEvent>
{
private readonly IParsingService _parsingService;
private readonly IHistoryService _historyService;
@ -281,16 +282,35 @@ namespace NzbDrone.Core.Download.TrackedDownloads
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();
t.RemoteEpisode?.Series != null &&
message.Series.Any(s => s.Id == t.RemoteEpisode.Series.Id))
.ToList();
if (cachedItems.Any())
if (cachedItems.Empty())
{
cachedItems.ForEach(UpdateCachedItem);
_eventAggregator.PublishEvent(new TrackedDownloadRefreshedEvent(GetTrackedDownloads()));
return;
}
cachedItems.ForEach(UpdateCachedItem);
_eventAggregator.PublishEvent(new TrackedDownloadRefreshedEvent(GetTrackedDownloads()));
}
public void Handle(SeriesEditedEvent message)
{
var cachedItems = _cache.Values.Where(t =>
t.RemoteEpisode?.Series != null &&
message.Series.Id == t.RemoteEpisode.Series.Id)
.ToList();
if (cachedItems.Empty())
{
return;
}
cachedItems.ForEach(UpdateCachedItem);
_eventAggregator.PublishEvent(new TrackedDownloadRefreshedEvent(GetTrackedDownloads()));
}
}
}

View File

@ -238,6 +238,15 @@ namespace NzbDrone.Core.Tv
_seriesRepository.UpdateMany(series);
_logger.Debug("{0} series updated", series.Count);
var updatedSeries = GetSeries(series.Select(s => s.Id));
foreach (var s in updatedSeries)
{
var oldSeries = series.Single(c => c.Id == s.Id);
_eventAggregator.PublishEvent(new SeriesEditedEvent(s, oldSeries));
}
return series;
}