Fixed: Don't Clean if no lists synced

Fixes #9011
This commit is contained in:
Qstick 2023-08-17 21:50:22 -05:00
parent fefdd71b6d
commit 927ae86e44
4 changed files with 35 additions and 2 deletions

View File

@ -59,7 +59,8 @@ namespace NzbDrone.Core.Test.ImportList
_importListFetch = new ImportListFetchResult
{
Movies = _list1Movies,
AnyFailure = false
AnyFailure = false,
SyncedLists = 1
};
_commandAll = new ImportListSyncCommand
@ -97,6 +98,11 @@ namespace NzbDrone.Core.Test.ImportList
_importListFetch.AnyFailure = true;
}
private void GivenNoListSync()
{
_importListFetch.SyncedLists = 0;
}
private void GivenCleanLevel(string cleanLevel)
{
Mocker.GetMock<IConfigService>()
@ -145,6 +151,26 @@ namespace NzbDrone.Core.Test.ImportList
.Verify(v => v.UpdateMovie(new List<Movie>(), true), Times.Never());
}
[Test]
public void should_not_clean_library_or_process_movies_if_no_synced_lists()
{
_importListFetch.Movies.ForEach(m => m.ListId = 1);
GivenList(1, true);
GivenCleanLevel("logOnly");
GivenNoListSync();
Subject.Execute(_commandAll);
Mocker.GetMock<IMovieService>()
.Verify(v => v.GetAllMovies(), Times.Never());
Mocker.GetMock<IMovieService>()
.Verify(v => v.UpdateMovie(new List<Movie>(), true), Times.Never());
Mocker.GetMock<IImportExclusionsService>()
.Verify(v => v.GetAllExclusions(), Times.Never);
}
[Test]
public void should_log_only_on_clean_library_if_config_value_logonly()
{

View File

@ -113,6 +113,7 @@ namespace NzbDrone.Core.ImportLists
}
result.AnyFailure |= importListReports.AnyFailure;
result.SyncedLists++;
_importListStatusService.UpdateListSyncStatus(importList.Definition.Id);
}
@ -130,7 +131,7 @@ namespace NzbDrone.Core.ImportLists
result.Movies = result.Movies.DistinctBy(r => new { r.TmdbId, r.ImdbId, r.Title }).ToList();
_logger.Debug("Found {0} total reports from {1} lists", result.Movies.Count, importLists.Count);
_logger.Debug("Found {0} total reports from {1} lists", result.Movies.Count, result.SyncedLists);
return result;
}

View File

@ -19,6 +19,7 @@ namespace NzbDrone.Core.ImportLists
public List<ImportListMovie> Movies { get; set; }
public bool AnyFailure { get; set; }
public int SyncedLists { get; set; }
}
public abstract class ImportListBase<TSettings> : IImportList

View File

@ -60,6 +60,11 @@ namespace NzbDrone.Core.ImportLists
return;
}
if (result.SyncedLists == 0)
{
return;
}
if (!result.AnyFailure)
{
CleanLibrary();