mirror of
https://github.com/Radarr/Radarr
synced 2025-02-23 06:41:20 +00:00
Prevent exception when renaming after script import
(cherry picked from commit 2166e4dce419ae477f2e4ce297bee2d8324a190e) Closes #9050
This commit is contained in:
parent
8e80c85f03
commit
99441dfa67
1 changed files with 10 additions and 16 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
var transfer = true;
|
||||
|
||||
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);
|
||||
|
||||
switch (scriptImportDecision)
|
||||
if (scriptImportDecision == ScriptImportDecision.RenameRequested)
|
||||
{
|
||||
case ScriptImportDecision.DeferMove:
|
||||
break;
|
||||
case ScriptImportDecision.RenameRequested:
|
||||
try
|
||||
{
|
||||
MoveMovieFile(movieFile, movie);
|
||||
transfer = false;
|
||||
break;
|
||||
case ScriptImportDecision.MoveComplete:
|
||||
transfer = false;
|
||||
break;
|
||||
}
|
||||
catch (SameFilenameException)
|
||||
{
|
||||
_logger.Debug("No rename was required. File already exists at destination.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (transfer)
|
||||
else
|
||||
{
|
||||
_diskTransferService.TransferFile(movieFilePath, destinationFilePath, mode);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue