diff --git a/src/NzbDrone.Core.Test/DataAugmentation/SceneNumbering/XemServiceFixture.cs b/src/NzbDrone.Core.Test/DataAugmentation/SceneNumbering/XemServiceFixture.cs index 99f522a79..be836a0e2 100644 --- a/src/NzbDrone.Core.Test/DataAugmentation/SceneNumbering/XemServiceFixture.cs +++ b/src/NzbDrone.Core.Test/DataAugmentation/SceneNumbering/XemServiceFixture.cs @@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering .Verify(v => v.GetSceneTvdbMappings(10), Times.Never()); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Never()); + .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } [Test] @@ -119,7 +119,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering Subject.Handle(new SeriesUpdatedEvent(_series)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.UseSceneNumbering == true), It.IsAny()), Times.Once()); + .Verify(v => v.UpdateSeries(It.Is(s => s.UseSceneNumbering == true), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering Subject.Handle(new SeriesUpdatedEvent(_series)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Once()); + .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -143,7 +143,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering Subject.Handle(new SeriesUpdatedEvent(_series)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Never()); + .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); ExceptionVerification.ExpectedWarns(1); } @@ -160,7 +160,7 @@ namespace NzbDrone.Core.Test.DataAugmentation.SceneNumbering Subject.Handle(new SeriesUpdatedEvent(_series)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Never()); + .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); ExceptionVerification.ExpectedWarns(1); } diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/LegacySetEpisodeMontitoredFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/LegacySetEpisodeMontitoredFixture.cs index 963c45d5b..f99b5e1dc 100644 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/LegacySetEpisodeMontitoredFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/LegacySetEpisodeMontitoredFixture.cs @@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests Subject.SetEpisodeMonitoredStatus(_series, null); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Once()); + .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); Mocker.GetMock() .Verify(v => v.UpdateEpisodes(It.IsAny>()), Times.Never()); @@ -249,13 +249,13 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests private void VerifySeasonMonitored(Func predicate) { Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => n.Monitored)), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => n.Monitored)), It.IsAny(), It.IsAny())); } private void VerifySeasonNotMonitored(Func predicate) { Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => !n.Monitored)), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => !n.Monitored)), It.IsAny(), It.IsAny())); } } } diff --git a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs index a0867a7b4..34755f71d 100644 --- a/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/EpisodeMonitoredServiceTests/SetEpisodeMontitoredFixture.cs @@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests Subject.SetEpisodeMonitoredStatus(_series, null); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Once()); + .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); Mocker.GetMock() .Verify(v => v.UpdateEpisodes(It.IsAny>()), Times.Never()); @@ -273,13 +273,13 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeMonitoredServiceTests private void VerifySeasonMonitored(Func predicate) { Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => n.Monitored)), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => n.Monitored)), It.IsAny(), It.IsAny())); } private void VerifySeasonNotMonitored(Func predicate) { Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => !n.Monitored)), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Where(predicate).All(n => !n.Monitored)), It.IsAny(), It.IsAny())); } } } diff --git a/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs index 523452754..7ca54f909 100644 --- a/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/MoveSeriesServiceFixture.cs @@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.TvTests ExceptionVerification.ExpectedErrors(1); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Once()); + .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); } [Test] diff --git a/src/NzbDrone.Core.Test/TvTests/RefreshSeriesServiceFixture.cs b/src/NzbDrone.Core.Test/TvTests/RefreshSeriesServiceFixture.cs index d59e30e8d..09e53fa04 100644 --- a/src/NzbDrone.Core.Test/TvTests/RefreshSeriesServiceFixture.cs +++ b/src/NzbDrone.Core.Test/TvTests/RefreshSeriesServiceFixture.cs @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 2).Monitored == true), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 2).Monitored == true), It.IsAny(), It.IsAny())); } [Test] @@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 2).Monitored == false), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 2).Monitored == false), It.IsAny(), It.IsAny())); } [Test] @@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 0).Monitored == false), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2 && s.Seasons.Single(season => season.SeasonNumber == 0).Monitored == false), It.IsAny(), It.IsAny())); } [Test] @@ -114,7 +114,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.TvRageId == newSeriesInfo.TvRageId), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.TvRageId == newSeriesInfo.TvRageId), It.IsAny(), It.IsAny())); } [Test] @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.TvMazeId == newSeriesInfo.TvMazeId), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.TvMazeId == newSeriesInfo.TvMazeId), It.IsAny(), It.IsAny())); } [Test] @@ -137,7 +137,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Status == SeriesStatusType.Deleted), It.IsAny()), Times.Once()); + .Verify(v => v.UpdateSeries(It.Is(s => s.Status == SeriesStatusType.Deleted), It.IsAny(), It.IsAny()), Times.Once()); ExceptionVerification.ExpectedErrors(1); } @@ -148,7 +148,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Status == SeriesStatusType.Deleted), It.IsAny()), Times.Once()); + .Verify(v => v.UpdateSeries(It.Is(s => s.Status == SeriesStatusType.Deleted), It.IsAny(), It.IsAny()), Times.Once()); ExceptionVerification.ExpectedErrors(1); } @@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny()), Times.Never()); + .Verify(v => v.UpdateSeries(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); ExceptionVerification.ExpectedErrors(1); } @@ -177,7 +177,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.TvdbId == newSeriesInfo.TvdbId), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.TvdbId == newSeriesInfo.TvdbId), It.IsAny(), It.IsAny())); ExceptionVerification.ExpectedWarns(1); } @@ -203,7 +203,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2), It.IsAny(), It.IsAny())); } [Test] @@ -223,7 +223,7 @@ namespace NzbDrone.Core.Test.TvTests Subject.Execute(new RefreshSeriesCommand(_series.Id)); Mocker.GetMock() - .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2), It.IsAny())); + .Verify(v => v.UpdateSeries(It.Is(s => s.Seasons.Count == 2), It.IsAny(), It.IsAny())); } diff --git a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs index 73911b39f..e1737d851 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -102,8 +102,9 @@ namespace NzbDrone.Core.MediaCover return Path.Combine(_coverRootFolder, seriesId.ToString()); } - private void EnsureCovers(Series series) + private bool EnsureCovers(Series series) { + bool updated = false; var toResize = new List>(); foreach (var cover in series.Images) @@ -116,6 +117,7 @@ namespace NzbDrone.Core.MediaCover if (!alreadyExists) { DownloadCover(series, cover); + updated = true; } } catch (WebException e) @@ -143,6 +145,8 @@ namespace NzbDrone.Core.MediaCover { _semaphore.Release(); } + + return updated; } private void DownloadCover(Series series, MediaCover cover) @@ -200,8 +204,11 @@ namespace NzbDrone.Core.MediaCover public void HandleAsync(SeriesUpdatedEvent message) { - EnsureCovers(message.Series); - _eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Series)); + var updated = EnsureCovers(message.Series); + if (updated) + { + _eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Series)); + } } public void HandleAsync(SeriesDeletedEvent message) diff --git a/src/NzbDrone.Core/Tv/RefreshSeriesService.cs b/src/NzbDrone.Core/Tv/RefreshSeriesService.cs index 3828a65f1..d15a27050 100644 --- a/src/NzbDrone.Core/Tv/RefreshSeriesService.cs +++ b/src/NzbDrone.Core/Tv/RefreshSeriesService.cs @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Tv if (series.Status != SeriesStatusType.Deleted) { series.Status = SeriesStatusType.Deleted; - _seriesService.UpdateSeries(series); + _seriesService.UpdateSeries(series, publishUpdatedEvent: false); _logger.Debug("Series marked as deleted on tvdb for {0}", series.Title); _eventAggregator.PublishEvent(new SeriesUpdatedEvent(series)); } @@ -110,7 +110,7 @@ namespace NzbDrone.Core.Tv series.Seasons = UpdateSeasons(series, seriesInfo); - _seriesService.UpdateSeries(series); + _seriesService.UpdateSeries(series, publishUpdatedEvent: false); _refreshEpisodeService.RefreshEpisodeInfo(series, episodes); _logger.Debug("Finished series refresh for {0}", series.Title); diff --git a/src/NzbDrone.Core/Tv/SeriesService.cs b/src/NzbDrone.Core/Tv/SeriesService.cs index f95c04d69..020f605a2 100644 --- a/src/NzbDrone.Core/Tv/SeriesService.cs +++ b/src/NzbDrone.Core/Tv/SeriesService.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Tv void DeleteSeries(int seriesId, bool deleteFiles); List GetAllSeries(); List AllForTag(int tagId); - Series UpdateSeries(Series series, bool updateEpisodesToMatchSeason = true); + Series UpdateSeries(Series series, bool updateEpisodesToMatchSeason = true, bool publishUpdatedEvent = true); List UpdateSeries(List series, bool useExistingRelativeFolder); bool SeriesPathExists(string folder); void RemoveAddOptions(Series series); @@ -165,7 +165,7 @@ namespace NzbDrone.Core.Tv // 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) + public Series UpdateSeries(Series series, bool updateEpisodesToMatchSeason = true, bool publishUpdatedEvent = true) { var storedSeries = GetSeries(series.Id); @@ -186,7 +186,10 @@ namespace NzbDrone.Core.Tv series.AddOptions = storedSeries.AddOptions; var updatedSeries = _seriesRepository.Update(series); - _eventAggregator.PublishEvent(new SeriesEditedEvent(updatedSeries, storedSeries)); + if (publishUpdatedEvent) + { + _eventAggregator.PublishEvent(new SeriesEditedEvent(updatedSeries, storedSeries)); + } return updatedSeries; }