From 2166e4dce419ae477f2e4ce297bee2d8324a190e Mon Sep 17 00:00:00 2001 From: Jendrik Weise Date: Wed, 16 Aug 2023 21:56:44 +0200 Subject: [PATCH] Prevent exception when renaming after script import --- .../MediaFiles/EpisodeFileMovingService.cs | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs index 161437723..3ea8a9fc1 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs @@ -121,29 +121,23 @@ namespace NzbDrone.Core.MediaFiles throw new SameFilenameException("File not moved, source and destination are the same", episodeFilePath); } - var transfer = true; - episodeFile.RelativePath = series.Path.GetRelativePath(destinationFilePath); - if (localEpisode is not null) + if (localEpisode is not null && _scriptImportDecider.TryImport(episodeFilePath, destinationFilePath, localEpisode, episodeFile, mode) is var scriptImportDecision && scriptImportDecision != ScriptImportDecision.DeferMove) { - var scriptImportDecision = _scriptImportDecider.TryImport(episodeFilePath, destinationFilePath, localEpisode, episodeFile, mode); - - switch (scriptImportDecision) + if (scriptImportDecision == ScriptImportDecision.RenameRequested) { - case ScriptImportDecision.DeferMove: - break; - case ScriptImportDecision.RenameRequested: + try + { MoveEpisodeFile(episodeFile, series, episodeFile.Episodes); - 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(episodeFilePath, destinationFilePath, mode); }