mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
Delete existing files on import if equal or better quality otherwise skip importing. If the folder is not deleted after processing it is renamed so it will not be processed repeatedly.
This commit is contained in:
parent
2ad200e743
commit
d554e9ec83
3 changed files with 205 additions and 11 deletions
|
@ -82,7 +82,6 @@ namespace NzbDrone.Core.Providers
|
|||
return importedFiles;
|
||||
}
|
||||
|
||||
|
||||
public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
{
|
||||
Logger.Trace("Importing file to database [{0}]", filePath);
|
||||
|
@ -114,13 +113,22 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
if (episodes.Count <= 0)
|
||||
{
|
||||
Logger.Debug("Can't find any matching episodes in the database. skipping. {0}", filePath);
|
||||
Logger.Debug("Can't find any matching episodes in the database. Skipping {0}", filePath);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (episodes.Any(e => e.EpisodeFile != null && e.EpisodeFile.QualityWrapper > parseResult.Quality))
|
||||
//Make sure this file is an upgrade for ALL episodes already on disk
|
||||
if (episodes.All(e => e.EpisodeFile == null || e.EpisodeFile.QualityWrapper <= parseResult.Quality))
|
||||
{
|
||||
Logger.Trace("File with better quality is already attached. skipping {0}", filePath);
|
||||
Logger.Debug("Deleting the existing file(s) on disk to upgrade to: {0}", filePath);
|
||||
//Do the delete for files where there is already an episode on disk
|
||||
episodes.Where(e => e.EpisodeFile != null).Select(e => e.EpisodeFile.Path).Distinct().ToList().ForEach(p => _diskProvider.DeleteFile(p));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//Skip this file because its not an upgrade
|
||||
Logger.Trace("This file isn't an upgrade for all episodes. Skipping {0}", filePath);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue