Fixed: Edited series is reset after refresh

Fixes #3892
This commit is contained in:
Mark McDowall 2020-08-02 11:47:03 -07:00
parent 0cc06fcba8
commit 5193f01c8c
1 changed files with 16 additions and 9 deletions

View File

@ -47,8 +47,12 @@ namespace NzbDrone.Core.Tv
_logger = logger; _logger = logger;
} }
private void RefreshSeriesInfo(Series series) private Series RefreshSeriesInfo(int seriesId)
{ {
// Get the series before updating, that way any changes made to the series after the refresh started,
// but before this series was refreshed won't be lost.
var series = _seriesService.GetSeries(seriesId);
_logger.ProgressInfo("Updating {0}", series.Title); _logger.ProgressInfo("Updating {0}", series.Title);
Series seriesInfo; Series seriesInfo;
@ -115,6 +119,8 @@ namespace NzbDrone.Core.Tv
_logger.Debug("Finished series refresh for {0}", series.Title); _logger.Debug("Finished series refresh for {0}", series.Title);
_eventAggregator.PublishEvent(new SeriesUpdatedEvent(series)); _eventAggregator.PublishEvent(new SeriesUpdatedEvent(series));
return series;
} }
private List<Season> UpdateSeasons(Series series, Series seriesInfo) private List<Season> UpdateSeasons(Series series, Series seriesInfo)
@ -196,7 +202,7 @@ namespace NzbDrone.Core.Tv
try try
{ {
RefreshSeriesInfo(series); series = RefreshSeriesInfo(message.SeriesId.Value);
RescanSeries(series, isNew, trigger); RescanSeries(series, isNew, trigger);
} }
catch (SeriesNotFoundException) catch (SeriesNotFoundException)
@ -216,29 +222,30 @@ namespace NzbDrone.Core.Tv
foreach (var series in allSeries) foreach (var series in allSeries)
{ {
if (trigger == CommandTrigger.Manual || _checkIfSeriesShouldBeRefreshed.ShouldRefresh(series)) var seriesLocal = series;
if (trigger == CommandTrigger.Manual || _checkIfSeriesShouldBeRefreshed.ShouldRefresh(seriesLocal))
{ {
try try
{ {
RefreshSeriesInfo(series); seriesLocal = RefreshSeriesInfo(seriesLocal.Id);
} }
catch (SeriesNotFoundException) catch (SeriesNotFoundException)
{ {
_logger.Error("Series '{0}' (tvdbid {1}) was not found, it may have been removed from TheTVDB.", series.Title, series.TvdbId); _logger.Error("Series '{0}' (tvdbid {1}) was not found, it may have been removed from TheTVDB.", seriesLocal.Title, seriesLocal.TvdbId);
continue; continue;
} }
catch (Exception e) catch (Exception e)
{ {
_logger.Error(e, "Couldn't refresh info for {0}", series); _logger.Error(e, "Couldn't refresh info for {0}", seriesLocal);
} }
RescanSeries(series, false, trigger); RescanSeries(seriesLocal, false, trigger);
} }
else else
{ {
_logger.Info("Skipping refresh of series: {0}", series.Title); _logger.Info("Skipping refresh of series: {0}", seriesLocal.Title);
RescanSeries(series, false, trigger); RescanSeries(seriesLocal, false, trigger);
} }
} }
} }