Move folder on rename; event doesn't fire yet

pull/2/head
Tim Turner 8 years ago
parent a691ffa7b7
commit f9923f4592

@ -60,7 +60,7 @@ namespace NzbDrone.Core.MediaFiles
var newFileName = _buildFileNames.BuildFileName(movie, movieFile); var newFileName = _buildFileNames.BuildFileName(movie, movieFile);
var filePath = _buildFileNames.BuildFilePath(movie, newFileName, Path.GetExtension(movieFile.RelativePath)); 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); _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 newFileName = _buildFileNames.BuildFileName(localMovie.Movie, movieFile);
var filePath = _buildFileNames.BuildFilePath(localMovie.Movie, newFileName, Path.GetExtension(localMovie.Path)); 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); _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 newFileName = _buildFileNames.BuildFileName(localMovie.Movie, movieFile);
var filePath = _buildFileNames.BuildFilePath(localMovie.Movie, newFileName, Path.GetExtension(localMovie.Path)); var filePath = _buildFileNames.BuildFilePath(localMovie.Movie, newFileName, Path.GetExtension(localMovie.Path));
EnsureMovieFolder(movieFile, localMovie, filePath); filePath = EnsureMovieFolder(movieFile, localMovie, filePath);
if (_configService.CopyUsingHardlinks) if (_configService.CopyUsingHardlinks)
{ {
@ -135,15 +135,17 @@ namespace NzbDrone.Core.MediaFiles
return movieFile; 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 movieFolder = Path.GetDirectoryName(filePath);
var rootFolder = new OsPath(movieFolder).Directory.FullPath; var rootFolder = new OsPath(movieFolder).Directory.FullPath;
var fileName = Path.GetFileName(filePath);
var newPath = "";
if (!_diskProvider.FolderExists(rootFolder)) if (!_diskProvider.FolderExists(rootFolder))
{ {
@ -157,6 +159,18 @@ namespace NzbDrone.Core.MediaFiles
{ {
CreateFolder(movieFolder); CreateFolder(movieFolder);
newEvent.SeriesFolder = 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; changed = true;
} }
@ -164,6 +178,8 @@ namespace NzbDrone.Core.MediaFiles
{ {
_eventAggregator.PublishEvent(newEvent); _eventAggregator.PublishEvent(newEvent);
} }
return newPath;
} }
private void CreateFolder(string directoryName) 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) private void RenameFiles(List<MovieFile> movieFiles, Movie movie)
{ {
var renamed = new List<MovieFile>(); var renamed = new List<MovieFile>();

Loading…
Cancel
Save