1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00

Opt out of updating episodes matching season monitored state when updating series

Fixed: Season pass resetting changes when a season changed it's monitored state
Closes #2139
This commit is contained in:
Mark McDowall 2017-08-19 00:26:42 -07:00
parent b8b0f05920
commit 078b53dc13
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0
6 changed files with 25 additions and 23 deletions

View File

@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
.Verify(v => v.GetSceneTvdbMappings(10), Times.Never()); .Verify(v => v.GetSceneTvdbMappings(10), Times.Never());
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never()); .Verify(v => v.UpdateSeries(It.IsAny<Series>(), It.IsAny<bool>()), Times.Never());
} }
[Test] [Test]
@ -119,7 +119,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
Subject.Handle(new SeriesUpdatedEvent(_series)); Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.UseSceneNumbering == true)), Times.Once()); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.UseSceneNumbering == true), It.IsAny<bool>()), Times.Once());
} }
[Test] [Test]
@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
Subject.Handle(new SeriesUpdatedEvent(_series)); Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Once()); .Verify(v => v.UpdateSeries(It.IsAny<Series>(), It.IsAny<bool>()), Times.Once());
} }
[Test] [Test]
@ -143,7 +143,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
Subject.Handle(new SeriesUpdatedEvent(_series)); Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never()); .Verify(v => v.UpdateSeries(It.IsAny<Series>(), It.IsAny<bool>()), Times.Never());
ExceptionVerification.ExpectedWarns(1); ExceptionVerification.ExpectedWarns(1);
} }
@ -160,7 +160,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering
Subject.Handle(new SeriesUpdatedEvent(_series)); Subject.Handle(new SeriesUpdatedEvent(_series));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never()); .Verify(v => v.UpdateSeries(It.IsAny<Series>(), It.IsAny<bool>()), Times.Never());
ExceptionVerification.ExpectedWarns(1); ExceptionVerification.ExpectedWarns(1);
} }

View File

@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
Subject.SetEpisodeMonitoredStatus(_series, null); Subject.SetEpisodeMonitoredStatus(_series, null);
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Once()); .Verify(v => v.UpdateSeries(It.IsAny<Series>(), It.IsAny<bool>()), Times.Once());
Mocker.GetMock<IEpisodeService>() Mocker.GetMock<IEpisodeService>()
.Verify(v => v.UpdateEpisodes(It.IsAny<List<Episode>>()), Times.Never()); .Verify(v => v.UpdateEpisodes(It.IsAny<List<Episode>>()), Times.Never());
@ -249,13 +249,13 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests
private void VerifySeasonMonitored(Func<Season, bool> predicate) private void VerifySeasonMonitored(Func<Season, bool> predicate)
{ {
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Where(predicate).All(n => n.Monitored)))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Where(predicate).All(n => n.Monitored)), It.IsAny<bool>()));
} }
private void VerifySeasonNotMonitored(Func<Season, bool> predicate) private void VerifySeasonNotMonitored(Func<Season, bool> predicate)
{ {
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Where(predicate).All(n => !n.Monitored)))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Where(predicate).All(n => !n.Monitored)), It.IsAny<bool>()));
} }
} }
} }

View File

@ -63,7 +63,7 @@ namespace NzbDrone.Core.Test.TvTests
ExceptionVerification.ExpectedErrors(1); ExceptionVerification.ExpectedErrors(1);
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never()); .Verify(v => v.UpdateSeries(It.IsAny<Series>(), It.IsAny<bool>()), Times.Never());
} }
[Test] [Test]
@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(_command); Subject.Execute(_command);
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Path == expectedPath)), Times.Once()); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Path == expectedPath), It.IsAny<bool>()), Times.Once());
} }
[Test] [Test]
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(_command); Subject.Execute(_command);
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Path == _command.DestinationPath)), Times.Once()); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Path == _command.DestinationPath), It.IsAny<bool>()), Times.Once());
Mocker.GetMock<IBuildFileNames>() Mocker.GetMock<IBuildFileNames>()
.Verify(v => v.GetSeriesFolder(It.IsAny<Series>(), null), Times.Never()); .Verify(v => v.GetSeriesFolder(It.IsAny<Series>(), null), Times.Never());

View File

@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(new RefreshSeriesCommand(_series.Id)); Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 2).Monitored == true))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 2).Monitored == true), It.IsAny<bool>()));
} }
[Test] [Test]
@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(new RefreshSeriesCommand(_series.Id)); Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 0).Monitored == false))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 0).Monitored == false), It.IsAny<bool>()));
} }
[Test] [Test]
@ -92,7 +92,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(new RefreshSeriesCommand(_series.Id)); Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.TvRageId == newSeriesInfo.TvRageId))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.TvRageId == newSeriesInfo.TvRageId), It.IsAny<bool>()));
} }
[Test] [Test]
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(new RefreshSeriesCommand(_series.Id)); Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.TvMazeId == newSeriesInfo.TvMazeId))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.TvMazeId == newSeriesInfo.TvMazeId), It.IsAny<bool>()));
} }
[Test] [Test]
@ -115,7 +115,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(new RefreshSeriesCommand(_series.Id)); Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Never()); .Verify(v => v.UpdateSeries(It.IsAny<Series>(), It.IsAny<bool>()), Times.Never());
ExceptionVerification.ExpectedErrors(1); ExceptionVerification.ExpectedErrors(1);
} }
@ -131,7 +131,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(new RefreshSeriesCommand(_series.Id)); Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.TvdbId == newSeriesInfo.TvdbId))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.TvdbId == newSeriesInfo.TvdbId), It.IsAny<bool>()));
ExceptionVerification.ExpectedWarns(1); ExceptionVerification.ExpectedWarns(1);
} }
@ -157,7 +157,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(new RefreshSeriesCommand(_series.Id)); Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2), It.IsAny<bool>()));
} }
[Test] [Test]
@ -177,7 +177,7 @@ namespace NzbDrone.Core.Test.TvTests
Subject.Execute(new RefreshSeriesCommand(_series.Id)); Subject.Execute(new RefreshSeriesCommand(_series.Id));
Mocker.GetMock<ISeriesService>() Mocker.GetMock<ISeriesService>()
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2))); .Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2), It.IsAny<bool>()));
} }
} }

View File

@ -83,7 +83,7 @@ namespace NzbDrone.Core.Tv
_episodeService.UpdateEpisodes(episodes); _episodeService.UpdateEpisodes(episodes);
} }
_seriesService.UpdateSeries(series); _seriesService.UpdateSeries(series, false);
} }
private void ToggleEpisodesMonitoredState(IEnumerable<Episode> episodes, bool monitored) private void ToggleEpisodesMonitoredState(IEnumerable<Episode> episodes, bool monitored)

View File

@ -25,7 +25,7 @@ namespace NzbDrone.Core.Tv
Series FindByTitleInexact(string title); Series FindByTitleInexact(string title);
void DeleteSeries(int seriesId, bool deleteFiles); void DeleteSeries(int seriesId, bool deleteFiles);
List<Series> GetAllSeries(); List<Series> GetAllSeries();
Series UpdateSeries(Series series); Series UpdateSeries(Series series, bool updateEpisodesToMatchSeason = true);
List<Series> UpdateSeries(List<Series> series); List<Series> UpdateSeries(List<Series> series);
bool SeriesPathExists(string folder); bool SeriesPathExists(string folder);
void RemoveAddOptions(Series series); void RemoveAddOptions(Series series);
@ -144,7 +144,9 @@ namespace NzbDrone.Core.Tv
return _seriesRepository.All().ToList(); return _seriesRepository.All().ToList();
} }
public Series UpdateSeries(Series series) // updateEpisodesToMatchSeason is an override for EpisodeMonitoredService to use so a change via Season pass doesn't get nuked by the seasons loop.
// TODO: Remove when seasons are split from series (or we come up with a better way to address this)
public Series UpdateSeries(Series series, bool updateEpisodesToMatchSeason = true)
{ {
var storedSeries = GetSeries(series.Id); var storedSeries = GetSeries(series.Id);
@ -152,7 +154,7 @@ namespace NzbDrone.Core.Tv
{ {
var storedSeason = storedSeries.Seasons.SingleOrDefault(s => s.SeasonNumber == season.SeasonNumber); var storedSeason = storedSeries.Seasons.SingleOrDefault(s => s.SeasonNumber == season.SeasonNumber);
if (storedSeason != null && season.Monitored != storedSeason.Monitored) if (storedSeason != null &&season.Monitored != storedSeason.Monitored && updateEpisodesToMatchSeason)
{ {
_episodeService.SetEpisodeMonitoredBySeason(series.Id, season.SeasonNumber, season.Monitored); _episodeService.SetEpisodeMonitoredBySeason(series.Id, season.SeasonNumber, season.Monitored);
} }