mirror of https://github.com/Sonarr/Sonarr
Improve renaming of series folder within the same root folder
This commit is contained in:
parent
6fed932a61
commit
4bc0ffa74d
|
@ -227,6 +227,14 @@ namespace NzbDrone.Common.Disk
|
|||
MoveFileInternal(source, destination);
|
||||
}
|
||||
|
||||
public void MoveFolder(string source, string destination)
|
||||
{
|
||||
Ensure.That(source, () => source).IsValidPath();
|
||||
Ensure.That(destination, () => destination).IsValidPath();
|
||||
|
||||
Directory.Move(source, destination);
|
||||
}
|
||||
|
||||
protected virtual void MoveFileInternal(string source, string destination)
|
||||
{
|
||||
File.Move(source, destination);
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace NzbDrone.Common.Disk
|
|||
void DeleteFile(string path);
|
||||
void CopyFile(string source, string destination, bool overwrite = false);
|
||||
void MoveFile(string source, string destination, bool overwrite = false);
|
||||
void MoveFolder(string source, string destination);
|
||||
bool TryCreateHardLink(string source, string destination);
|
||||
void DeleteFolder(string path, bool recursive);
|
||||
string ReadAllText(string filePath);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Instrumentation.Extensions;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Tv.Commands;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
|
||||
|
@ -16,6 +18,7 @@ namespace NzbDrone.Core.Tv
|
|||
private readonly IBuildFileNames _filenameBuilder;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IDiskTransferService _diskTransferService;
|
||||
private readonly IRootFolderService _rootFolderService;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly Logger _logger;
|
||||
|
||||
|
@ -23,6 +26,7 @@ namespace NzbDrone.Core.Tv
|
|||
IBuildFileNames filenameBuilder,
|
||||
IDiskProvider diskProvider,
|
||||
IDiskTransferService diskTransferService,
|
||||
IRootFolderService rootFolderService,
|
||||
IEventAggregator eventAggregator,
|
||||
Logger logger)
|
||||
{
|
||||
|
@ -30,6 +34,7 @@ namespace NzbDrone.Core.Tv
|
|||
_filenameBuilder = filenameBuilder;
|
||||
_diskProvider = diskProvider;
|
||||
_diskTransferService = diskTransferService;
|
||||
_rootFolderService = rootFolderService;
|
||||
_eventAggregator = eventAggregator;
|
||||
_logger = logger;
|
||||
}
|
||||
|
@ -52,8 +57,19 @@ namespace NzbDrone.Core.Tv
|
|||
}
|
||||
|
||||
try
|
||||
{
|
||||
var sourceRootFolder = _rootFolderService.GetBestRootFolderPath(sourcePath);
|
||||
var destinationRootFolder = _rootFolderService.GetBestRootFolderPath(destinationPath);
|
||||
|
||||
if (sourceRootFolder.PathEquals(destinationRootFolder) && !_diskProvider.FolderExists(destinationPath))
|
||||
{
|
||||
_diskProvider.MoveFolder(sourcePath, destinationPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_diskTransferService.TransferFolder(sourcePath, destinationPath, TransferMode.Move);
|
||||
}
|
||||
|
||||
_logger.ProgressInfo("{0} moved successfully to {1}", series.Title, series.Path);
|
||||
|
||||
_eventAggregator.PublishEvent(new SeriesMovedEvent(series, sourcePath, destinationPath));
|
||||
|
|
Loading…
Reference in New Issue