New: Don't process files during Manual Import if there are more than 100 items

Fixes #5357

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
pull/5848/head
Qstick 4 years ago
parent 2a93686360
commit e5f66da087

@ -108,8 +108,8 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual
SceneSource = SceneSource(movie, rootFolder), SceneSource = SceneSource(movie, rootFolder),
ExistingFile = movie.Path.IsParentPath(path), ExistingFile = movie.Path.IsParentPath(path),
Size = _diskProvider.GetFileSize(path), Size = _diskProvider.GetFileSize(path),
Languages = languages, Languages = (languages?.SingleOrDefault() ?? Language.Unknown) == Language.Unknown ? LanguageParser.ParseLanguages(path) : languages,
Quality = quality Quality = quality.Quality == Quality.Unknown ? QualityParser.ParseQuality(path) : quality
}; };
return MapItem(_importDecisionMaker.GetDecision(localEpisode, downloadClientItem), rootFolder, downloadId, null); return MapItem(_importDecisionMaker.GetDecision(localEpisode, downloadClientItem), rootFolder, downloadId, null);
@ -140,7 +140,14 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual
// Filter paths based on the rootFolder, so files in subfolders that should be ignored are ignored. // Filter paths based on the rootFolder, so files in subfolders that should be ignored are ignored.
// It will lead to some extra directories being checked for files, but it saves the processing of them and is cleaner than // It will lead to some extra directories being checked for files, but it saves the processing of them and is cleaner than
// teaching FilterPaths to know whether it's processing a file or a folder and changing it's filtering based on that. // teaching FilterPaths to know whether it's processing a file or a folder and changing it's filtering based on that.
// If the movie is unknown for the directory and there are more than 100 files in the folder don't process the items before returning.
var files = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder, false)); var files = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder, false));
if (files.Count() > 100)
{
return ProcessDownloadDirectory(rootFolder, files);
}
var subfolders = _diskScanService.FilterPaths(rootFolder, _diskProvider.GetDirectories(baseFolder)); var subfolders = _diskScanService.FilterPaths(rootFolder, _diskProvider.GetDirectories(baseFolder));
var processedFiles = files.Select(file => ProcessFile(rootFolder, baseFolder, file, downloadId)); var processedFiles = files.Select(file => ProcessFile(rootFolder, baseFolder, file, downloadId));
@ -214,6 +221,24 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual
}; };
} }
private List<ManualImportItem> ProcessDownloadDirectory(string rootFolder, List<string> videoFiles)
{
var items = new List<ManualImportItem>();
foreach (var file in videoFiles)
{
var localEpisode = new LocalMovie();
localEpisode.Path = file;
localEpisode.Quality = new QualityModel(Quality.Unknown);
localEpisode.Languages = new List<Language> { Language.Unknown };
localEpisode.Size = _diskProvider.GetFileSize(file);
items.Add(MapItem(new ImportDecision(localEpisode), rootFolder, null, null));
}
return items;
}
private bool SceneSource(Movie movie, string folder) private bool SceneSource(Movie movie, string folder)
{ {
return !(movie.Path.PathEquals(folder) || movie.Path.IsParentPath(folder)); return !(movie.Path.PathEquals(folder) || movie.Path.IsParentPath(folder));

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Core.Languages;
using NzbDrone.Core.MediaFiles.MovieImport.Manual; using NzbDrone.Core.MediaFiles.MovieImport.Manual;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using Radarr.Api.V3.Movies; using Radarr.Api.V3.Movies;
@ -41,9 +42,17 @@ namespace Radarr.Api.V3.ManualImport
item.Movie = processedItem.Movie.ToResource(0); item.Movie = processedItem.Movie.ToResource(0);
item.Rejections = processedItem.Rejections; item.Rejections = processedItem.Rejections;
if (item.Languages.Single() == Language.Unknown)
{
item.Languages = processedItem.Languages; item.Languages = processedItem.Languages;
} }
if (item.Quality?.Quality == Quality.Unknown)
{
item.Quality = processedItem.Quality;
}
}
return items; return items;
} }

Loading…
Cancel
Save