Move folder on rename; event doesn't fire yet

Tim Turner 8 years ago
parent a691ffa7b7
commit f9923f4592

@ -60,7 +60,7 @@ namespace NzbDrone.Core.MediaFiles
var newFileName = _buildFileNames.BuildFileName(movie, movieFile);
var filePath = _buildFileNames.BuildFilePath(movie, newFileName, Path.GetExtension(movieFile.RelativePath));
EnsureMovieFolder(movieFile, movie, filePath);
filePath = EnsureMovieFolder(movieFile, movie, filePath);
_logger.Debug("Renaming movie file: {0} to {1}", movieFile, filePath);
@ -72,7 +72,7 @@ namespace NzbDrone.Core.MediaFiles
var newFileName = _buildFileNames.BuildFileName(localMovie.Movie, movieFile);
var filePath = _buildFileNames.BuildFilePath(localMovie.Movie, newFileName, Path.GetExtension(localMovie.Path));
EnsureMovieFolder(movieFile, localMovie, filePath);
filePath = EnsureMovieFolder(movieFile, localMovie, filePath);
_logger.Debug("Moving movie file: {0} to {1}", movieFile.Path, filePath);
@ -84,7 +84,7 @@ namespace NzbDrone.Core.MediaFiles
var newFileName = _buildFileNames.BuildFileName(localMovie.Movie, movieFile);
var filePath = _buildFileNames.BuildFilePath(localMovie.Movie, newFileName, Path.GetExtension(localMovie.Path));
EnsureMovieFolder(movieFile, localMovie, filePath);
filePath = EnsureMovieFolder(movieFile, localMovie, filePath);
if (_configService.CopyUsingHardlinks)
{
@ -135,15 +135,17 @@ namespace NzbDrone.Core.MediaFiles
return movieFile;
}
private void EnsureMovieFolder(MovieFile movieFile, LocalMovie localMovie, string filePath)
private string EnsureMovieFolder(MovieFile movieFile, LocalMovie localMovie, string filePath)
{
EnsureMovieFolder(movieFile, localMovie.Movie, filePath);
return EnsureMovieFolder(movieFile, localMovie.Movie, filePath);
}
private void EnsureMovieFolder(MovieFile movieFile, Movie movie, string filePath)
private string EnsureMovieFolder(MovieFile movieFile, Movie movie, string filePath)
{
var movieFolder = Path.GetDirectoryName(filePath);
var rootFolder = new OsPath(movieFolder).Directory.FullPath;
var fileName = Path.GetFileName(filePath);
var newPath = "";
if (!_diskProvider.FolderExists(rootFolder))
{
@ -157,6 +159,18 @@ namespace NzbDrone.Core.MediaFiles
{
CreateFolder(movieFolder);
newEvent.SeriesFolder = movieFolder;
newPath = Path.Combine(rootFolder, movieFolder, fileName);
changed = true;
}
var newFolder = _buildFileNames.GetMovieFolder(movie);
if(_diskProvider.FolderExists(movieFolder) && movieFolder != newFolder)
{
newFolder = Path.Combine(rootFolder, newFolder);
CreateFolder(newFolder);
newEvent.SeriesFolder = newFolder;
newPath = Path.Combine(newFolder, fileName);
changed = true;
}
@ -164,6 +178,8 @@ namespace NzbDrone.Core.MediaFiles
{
_eventAggregator.PublishEvent(newEvent);
}
return newPath;
}
private void CreateFolder(string directoryName)

@ -80,6 +80,16 @@ namespace NzbDrone.Core.MediaFiles
}
private void RenameMovieFiles(List<MovieFile> movieFiles, Movie movie)
{
}
private void RenameFolder(Movie movie)
{
}
private void RenameFiles(List<MovieFile> movieFiles, Movie movie)
{
var renamed = new List<MovieFile>();

Loading…
Cancel
Save