diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFileMoveResult.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFileMoveResult.cs index 978d60930..e88a10d29 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFileMoveResult.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeFileMoveResult.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.MediaFiles { @@ -10,7 +9,7 @@ namespace NzbDrone.Core.MediaFiles OldFiles = new List(); } - public String Path { get; set; } + public EpisodeFile EpisodeFile { get; set; } public List OldFiles { get; set; } } } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs index f71463f24..f3c5e321d 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs @@ -15,8 +15,8 @@ namespace NzbDrone.Core.MediaFiles { public interface IMoveEpisodeFiles { - string MoveEpisodeFile(EpisodeFile episodeFile, Series series); - string MoveEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode); + EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, Series series); + EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode); } public class EpisodeFileMovingService : IMoveEpisodeFiles @@ -40,7 +40,7 @@ namespace NzbDrone.Core.MediaFiles _logger = logger; } - public string MoveEpisodeFile(EpisodeFile episodeFile, Series series) + public EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, Series series) { var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id); var newFileName = _buildFileNames.BuildFilename(episodes, series, episodeFile); @@ -49,10 +49,10 @@ namespace NzbDrone.Core.MediaFiles _logger.Trace("Renaming episode file: {0} to {1}", episodeFile, filePath); MoveFile(episodeFile, series, filePath); - return filePath; + return episodeFile; } - public string MoveEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode) + public EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, LocalEpisode localEpisode) { var newFileName = _buildFileNames.BuildFilename(localEpisode.Episodes, localEpisode.Series, episodeFile); var filePath = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path)); @@ -60,10 +60,10 @@ namespace NzbDrone.Core.MediaFiles _logger.Trace("Moving episode file: {0} to {1}", episodeFile, filePath); MoveFile(episodeFile, localEpisode.Series, filePath); - return filePath; + return episodeFile; } - private void MoveFile(EpisodeFile episodeFile, Series series, string destinationFilename) + private EpisodeFile MoveFile(EpisodeFile episodeFile, Series series, string destinationFilename) { Ensure.That(episodeFile, () => episodeFile).IsNotNull(); Ensure.That(series,() => series).IsNotNull(); @@ -94,6 +94,7 @@ namespace NzbDrone.Core.MediaFiles _logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, destinationFilename); _diskProvider.MoveFile(episodeFile.Path, destinationFilename); + episodeFile.Path = destinationFilename; try { @@ -141,6 +142,8 @@ namespace NzbDrone.Core.MediaFiles { SetPermissions(destinationFilename, _configService.FileChmod); } + + return episodeFile; } private void SetPermissions(string path, string permissions) diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs index 713e45a7d..a62dd7536 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs @@ -80,7 +80,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport { episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanFilePath()); var moveResult = _episodeFileUpgrader.UpgradeEpisodeFile(episodeFile, localEpisode); - episodeFile.Path = moveResult.Path; oldFiles = moveResult.OldFiles; } diff --git a/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs b/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs index 315bd7894..d66298c8c 100644 --- a/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs @@ -116,7 +116,7 @@ namespace NzbDrone.Core.MediaFiles try { _logger.Trace("Renaming episode file: {0}", episodeFile); - episodeFile.Path = _episodeFileMover.MoveEpisodeFile(episodeFile, series); + _episodeFileMover.MoveEpisodeFile(episodeFile, series); _mediaFileService.Update(episodeFile); renamed.Add(episodeFile); diff --git a/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs b/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs index 87bd5349a..7fa4d5612 100644 --- a/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/UpgradeMediaFileService.cs @@ -54,7 +54,7 @@ namespace NzbDrone.Core.MediaFiles _mediaFileService.Delete(file, true); } - moveFileResult.Path = _episodeFileMover.MoveEpisodeFile(episodeFile, localEpisode); + moveFileResult.EpisodeFile = _episodeFileMover.MoveEpisodeFile(episodeFile, localEpisode); return moveFileResult; }