mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-18 16:29:41 +02:00
Avoid using GetAllMovies in DeleteBadMediaCovers
This commit is contained in:
parent
7a5ae56a96
commit
1c99ce8876
@ -20,25 +20,25 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
public class DeleteBadMediaCoversFixture : CoreTest<DeleteBadMediaCovers>
|
||||
{
|
||||
private List<MetadataFile> _metadata;
|
||||
private List<Movie> _movies;
|
||||
private Dictionary<int, string> _movies;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_movies = Builder<Movie>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(c => c.Path = "C:\\Movie\\".AsOsAgnostic())
|
||||
.Build().ToList();
|
||||
_movies = new Dictionary<int, string>
|
||||
{
|
||||
{ 1, "C:\\Movie\\".AsOsAgnostic() }
|
||||
};
|
||||
|
||||
_metadata = Builder<MetadataFile>.CreateListOfSize(1)
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<IMovieService>()
|
||||
.Setup(c => c.GetAllMovies())
|
||||
.Setup(c => c.AllMoviePaths())
|
||||
.Returns(_movies);
|
||||
|
||||
Mocker.GetMock<IMetadataFileService>()
|
||||
.Setup(c => c.GetFilesByMovie(_movies.First().Id))
|
||||
.Setup(c => c.GetFilesByMovie(_movies.First().Key))
|
||||
.Returns(_metadata);
|
||||
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.CleanupMetadataImages).Returns(true);
|
||||
@ -73,7 +73,7 @@ public void should_not_run_if_flag_is_false()
|
||||
Subject.Clean();
|
||||
|
||||
Mocker.GetMock<IConfigService>().VerifySet(c => c.CleanupMetadataImages = true, Times.Never());
|
||||
Mocker.GetMock<IMovieService>().Verify(c => c.GetAllMovies(), Times.Never());
|
||||
Mocker.GetMock<IMovieService>().Verify(c => c.AllMoviePaths(), Times.Never());
|
||||
|
||||
AssertImageWasNotRemoved();
|
||||
}
|
@ -37,18 +37,18 @@ public void Clean()
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user