1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-02-23 14:51:17 +00:00

Prevent exception when renaming after script import

(cherry picked from commit 2166e4dce419ae477f2e4ce297bee2d8324a190e)

Closes #9050
This commit is contained in:
Jendrik Weise 2023-08-16 21:56:44 +02:00 committed by Bogdan
parent 8e80c85f03
commit 99441dfa67

View file

@ -117,29 +117,23 @@ private MovieFile TransferFile(MovieFile movieFile, Movie movie, string destinat
throw new SameFilenameException("File not moved, source and destination are the same", movieFilePath); throw new SameFilenameException("File not moved, source and destination are the same", movieFilePath);
} }
var transfer = true;
movieFile.RelativePath = movie.Path.GetRelativePath(destinationFilePath); movieFile.RelativePath = movie.Path.GetRelativePath(destinationFilePath);
if (localMovie is not null) if (localMovie is not null && _scriptImportDecider.TryImport(movieFilePath, destinationFilePath, localMovie, movieFile, mode) is var scriptImportDecision && scriptImportDecision != ScriptImportDecision.DeferMove)
{ {
var scriptImportDecision = _scriptImportDecider.TryImport(movieFilePath, destinationFilePath, localMovie, movieFile, mode); if (scriptImportDecision == ScriptImportDecision.RenameRequested)
switch (scriptImportDecision)
{ {
case ScriptImportDecision.DeferMove: try
break; {
case ScriptImportDecision.RenameRequested:
MoveMovieFile(movieFile, movie); MoveMovieFile(movieFile, movie);
transfer = false; }
break; catch (SameFilenameException)
case ScriptImportDecision.MoveComplete: {
transfer = false; _logger.Debug("No rename was required. File already exists at destination.");
break; }
} }
} }
else
if (transfer)
{ {
_diskTransferService.TransferFile(movieFilePath, destinationFilePath, mode); _diskTransferService.TransferFile(movieFilePath, destinationFilePath, mode);
} }