Prevent exception when renaming after script import

(cherry picked from commit 2166e4dce419ae477f2e4ce297bee2d8324a190e)

Closes #9050
pull/9079/head
Jendrik Weise 1 year ago committed by Bogdan
parent 8e80c85f03
commit 99441dfa67

@ -117,29 +117,23 @@ namespace NzbDrone.Core.MediaFiles
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);
} }

Loading…
Cancel
Save