From 1c99ce88760adaa479276eb341c8642e0e0515ac Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 9 Jul 2023 23:19:21 -0500 Subject: [PATCH] Avoid using GetAllMovies in DeleteBadMediaCovers --- ...aCovers.cs => DeleteBadMediaCoversFixture.cs} | 16 ++++++++-------- .../Housekeepers/DeleteBadMediaCovers.cs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) rename src/NzbDrone.Core.Test/HealthCheck/Checks/{DeleteBadMediaCovers.cs => DeleteBadMediaCoversFixture.cs} (92%) diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCoversFixture.cs similarity index 92% rename from src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs rename to src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCoversFixture.cs index 7b791e91f..659a8d5c2 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCovers.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/DeleteBadMediaCoversFixture.cs @@ -20,25 +20,25 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks public class DeleteBadMediaCoversFixture : CoreTest { private List _metadata; - private List _movies; + private Dictionary _movies; [SetUp] public void Setup() { - _movies = Builder.CreateListOfSize(1) - .All() - .With(c => c.Path = "C:\\Movie\\".AsOsAgnostic()) - .Build().ToList(); + _movies = new Dictionary + { + { 1, "C:\\Movie\\".AsOsAgnostic() } + }; _metadata = Builder.CreateListOfSize(1) .Build().ToList(); Mocker.GetMock() - .Setup(c => c.GetAllMovies()) + .Setup(c => c.AllMoviePaths()) .Returns(_movies); Mocker.GetMock() - .Setup(c => c.GetFilesByMovie(_movies.First().Id)) + .Setup(c => c.GetFilesByMovie(_movies.First().Key)) .Returns(_metadata); Mocker.GetMock().SetupGet(c => c.CleanupMetadataImages).Returns(true); @@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks Subject.Clean(); Mocker.GetMock().VerifySet(c => c.CleanupMetadataImages = true, Times.Never()); - Mocker.GetMock().Verify(c => c.GetAllMovies(), Times.Never()); + Mocker.GetMock().Verify(c => c.AllMoviePaths(), Times.Never()); AssertImageWasNotRemoved(); } diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs index 1ba7f83d5..e8a489bcb 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/DeleteBadMediaCovers.cs @@ -37,18 +37,18 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers return; } - var movies = _movieService.GetAllMovies(); + var movies = _movieService.AllMoviePaths(); foreach (var movie in movies) { - var images = _metaFileService.GetFilesByMovie(movie.Id) + var images = _metaFileService.GetFilesByMovie(movie.Key) .Where(c => c.LastUpdated > new DateTime(2014, 12, 27) && c.RelativePath.EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase)); foreach (var image in images) { try { - var path = Path.Combine(movie.Path, image.RelativePath); + var path = Path.Combine(movie.Value, image.RelativePath); if (!IsValid(path)) { _logger.Debug("Deleting invalid image file " + path);