mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 02:22:31 +01:00
Fixed: Do not remove directories when they contain a RAR file over 10MB
This commit is contained in:
parent
fea906d45d
commit
6711ba2549
@ -77,7 +77,6 @@ private void GivenSuccessfulImport()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[TestCase(DownloadItemStatus.Downloading)]
|
||||
[TestCase(DownloadItemStatus.Failed)]
|
||||
[TestCase(DownloadItemStatus.Queued)]
|
||||
@ -92,7 +91,6 @@ public void should_not_process_if_download_status_isnt_completed(DownloadItemSta
|
||||
AssertNoAttemptedImport();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_not_process_if_matching_history_is_not_found_and_no_category_specified()
|
||||
{
|
||||
@ -116,8 +114,6 @@ public void should_process_if_matching_history_is_not_found_but_category_specifi
|
||||
AssertCompletedDownload();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_not_process_if_storage_directory_in_drone_factory()
|
||||
{
|
||||
@ -132,7 +128,6 @@ public void should_not_process_if_storage_directory_in_drone_factory()
|
||||
AssertNoAttemptedImport();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_not_process_if_output_path_is_empty()
|
||||
{
|
||||
@ -143,7 +138,6 @@ public void should_not_process_if_output_path_is_empty()
|
||||
AssertNoAttemptedImport();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_not_mark_as_imported_if_all_files_were_rejected()
|
||||
{
|
||||
|
@ -210,6 +210,48 @@ public void should_return_importresult_on_unknown_series()
|
||||
result.First().Result.Should().Be(ImportResultType.Rejected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_delete_if_there_is_large_rar_file()
|
||||
{
|
||||
GivenValidSeries();
|
||||
|
||||
var localEpisode = new LocalEpisode();
|
||||
|
||||
var imported = new List<ImportDecision>();
|
||||
imported.Add(new ImportDecision(localEpisode));
|
||||
|
||||
Mocker.GetMock<IMakeImportDecision>()
|
||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<String>>(), It.IsAny<Series>(), true, null))
|
||||
.Returns(imported);
|
||||
|
||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null))
|
||||
.Returns(imported.Select(i => new ImportResult(i)).ToList());
|
||||
|
||||
Mocker.GetMock<ISampleService>()
|
||||
.Setup(s => s.IsSample(It.IsAny<Series>(),
|
||||
It.IsAny<QualityModel>(),
|
||||
It.IsAny<String>(),
|
||||
It.IsAny<Int64>(),
|
||||
It.IsAny<Int32>()))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFiles(It.IsAny<string>(), SearchOption.AllDirectories))
|
||||
.Returns(new []{ _videoFiles.First().Replace(".ext", ".rar") });
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(s => s.GetFileSize(It.IsAny<string>()))
|
||||
.Returns(15.Megabytes());
|
||||
|
||||
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.DeleteFolder(It.IsAny<String>(), true), Times.Never());
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
private void VerifyNoImport()
|
||||
{
|
||||
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null),
|
||||
|
@ -48,8 +48,6 @@ private List<ImportResult> ProcessDroneFactoryFolder()
|
||||
return _downloadedEpisodesImportService.ProcessRootFolder(new DirectoryInfo(downloadedEpisodesFolder));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Execute(DownloadedEpisodesScanCommand message)
|
||||
{
|
||||
var importResults = ProcessDroneFactoryFolder();
|
||||
|
@ -183,6 +183,7 @@ private string GetCleanedUpFolderName(string folder)
|
||||
private bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series)
|
||||
{
|
||||
var videoFiles = _diskScanService.GetVideoFiles(directoryInfo.FullName);
|
||||
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f) == ".rar");
|
||||
|
||||
foreach (var videoFile in videoFiles)
|
||||
{
|
||||
@ -205,6 +206,12 @@ private bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series)
|
||||
}
|
||||
}
|
||||
|
||||
if (rarFiles.Any(f => _diskProvider.GetFileSize(f) > 10.Megabytes()))
|
||||
{
|
||||
_logger.Warn("RAR file detected, will require manual cleanup");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user