1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Block Video Extras from Overriding Movie File

This commit is contained in:
Qstick 2020-08-05 01:52:41 -04:00
parent 43d6b404f5
commit a29de48e64
3 changed files with 15 additions and 4 deletions

View File

@ -64,7 +64,7 @@ public void ImportExtraFiles(LocalMovie localMovie, MovieFile movieFile, bool is
var sourcePath = localMovie.Path; var sourcePath = localMovie.Path;
var sourceFolder = _diskProvider.GetParentFolder(sourcePath); var sourceFolder = _diskProvider.GetParentFolder(sourcePath);
var sourceFileName = Path.GetFileNameWithoutExtension(sourcePath); var sourceFileName = Path.GetFileNameWithoutExtension(sourcePath);
var files = _diskProvider.GetFiles(sourceFolder, SearchOption.TopDirectoryOnly); var files = _diskProvider.GetFiles(sourceFolder, SearchOption.TopDirectoryOnly).Where(f => f != localMovie.Path);
var wantedExtensions = _configService.ExtraFileExtensions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) var wantedExtensions = _configService.ExtraFileExtensions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(e => e.Trim(' ', '.')) .Select(e => e.Trim(' ', '.'))

View File

@ -49,7 +49,8 @@ public ExtraFileManager(IConfigService configService,
protected TExtraFile ImportFile(Movie movie, MovieFile movieFile, string path, bool readOnly, string extension, string fileNameSuffix = null) protected TExtraFile ImportFile(Movie movie, MovieFile movieFile, string path, bool readOnly, string extension, string fileNameSuffix = null)
{ {
var newFolder = Path.GetDirectoryName(Path.Combine(movie.Path, movieFile.RelativePath)); var movieFilePath = Path.Combine(movie.Path, movieFile.RelativePath);
var newFolder = Path.GetDirectoryName(movieFilePath);
var filenameBuilder = new StringBuilder(Path.GetFileNameWithoutExtension(movieFile.RelativePath)); var filenameBuilder = new StringBuilder(Path.GetFileNameWithoutExtension(movieFile.RelativePath));
if (fileNameSuffix.IsNotNullOrWhiteSpace()) if (fileNameSuffix.IsNotNullOrWhiteSpace())
@ -60,6 +61,13 @@ protected TExtraFile ImportFile(Movie movie, MovieFile movieFile, string path, b
filenameBuilder.Append(extension); filenameBuilder.Append(extension);
var newFileName = Path.Combine(newFolder, filenameBuilder.ToString()); var newFileName = Path.Combine(newFolder, filenameBuilder.ToString());
if (newFileName == movieFilePath)
{
_logger.Debug("Extra file {0} not imported, due to naming interference with movie file", path);
return null;
}
var transferMode = TransferMode.Move; var transferMode = TransferMode.Move;
if (readOnly) if (readOnly)

View File

@ -68,8 +68,11 @@ public override ExtraFile Import(Movie movie, MovieFile movieFile, string path,
{ {
var extraFile = ImportFile(movie, movieFile, path, readOnly, extension, null); var extraFile = ImportFile(movie, movieFile, path, readOnly, extension, null);
if (extraFile != null)
{
_mediaFileAttributeService.SetFilePermissions(path); _mediaFileAttributeService.SetFilePermissions(path);
_otherExtraFileService.Upsert(extraFile); _otherExtraFileService.Upsert(extraFile);
}
return extraFile; return extraFile;
} }