|
|
|
@ -36,42 +36,29 @@ namespace NzbDrone.Core.MediaFiles
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MovieFileMoveResult UpgradeMovieFile(MovieFile episodeFile, LocalMovie localEpisode, bool copyOnly = false)
|
|
|
|
|
public MovieFileMoveResult UpgradeMovieFile(MovieFile movieFile, LocalMovie localMovie, bool copyOnly = false)
|
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Upgrading existing episode file.");
|
|
|
|
|
_logger.Trace("Upgrading existing movie file.");
|
|
|
|
|
var moveFileResult = new MovieFileMoveResult();
|
|
|
|
|
localEpisode.Movie.MovieFile.LazyLoad();
|
|
|
|
|
var existingFile = localEpisode.Movie.MovieFile;
|
|
|
|
|
existingFile.LazyLoad();
|
|
|
|
|
|
|
|
|
|
if (existingFile.IsLoaded && existingFile.Value != null)
|
|
|
|
|
{
|
|
|
|
|
var file = existingFile.Value;
|
|
|
|
|
var episodeFilePath = Path.Combine(localEpisode.Movie.Path, file.RelativePath);
|
|
|
|
|
|
|
|
|
|
if (_diskProvider.FileExists(episodeFilePath))
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("Removing existing episode file: {0}", file);
|
|
|
|
|
_recycleBinProvider.DeleteFile(episodeFilePath);
|
|
|
|
|
}
|
|
|
|
|
var existingFile = localMovie.Movie.MovieFile.Value;
|
|
|
|
|
var movieFilePath = Path.Combine(localMovie.Movie.Path, existingFile.RelativePath);
|
|
|
|
|
|
|
|
|
|
moveFileResult.OldFiles.Add(file);
|
|
|
|
|
_mediaFileService.Delete(file, DeleteMediaFileReason.Upgrade);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (_diskProvider.FileExists(movieFilePath))
|
|
|
|
|
{
|
|
|
|
|
//_logger.Warn("The existing movie file was not lazy loaded.");
|
|
|
|
|
_logger.Debug("Removing existing movie file: {0}", existingFile);
|
|
|
|
|
_recycleBinProvider.DeleteFile(movieFilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
moveFileResult.OldFiles.Add(existingFile);
|
|
|
|
|
_mediaFileService.Delete(existingFile, DeleteMediaFileReason.Upgrade);
|
|
|
|
|
if (copyOnly)
|
|
|
|
|
{
|
|
|
|
|
moveFileResult.MovieFile = _movieFileMover.CopyMovieFile(episodeFile, localEpisode);
|
|
|
|
|
moveFileResult.MovieFile = _movieFileMover.CopyMovieFile(movieFile, localMovie);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
moveFileResult.MovieFile= _movieFileMover.MoveMovieFile(episodeFile, localEpisode);
|
|
|
|
|
moveFileResult.MovieFile = _movieFileMover.MoveMovieFile(movieFile, localMovie);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return moveFileResult;
|
|
|
|
|