From 4bc0ffa74d06659f0658b1a901a6ae3765aca921 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 11 Jan 2019 19:34:35 -0800 Subject: [PATCH] Improve renaming of series folder within the same root folder --- src/NzbDrone.Common/Disk/DiskProviderBase.cs | 8 ++++++++ src/NzbDrone.Common/Disk/IDiskProvider.cs | 1 + src/NzbDrone.Core/Tv/MoveSeriesService.cs | 18 +++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index 916bcceb9..eb9fa82c0 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -227,6 +227,14 @@ public void MoveFile(string source, string destination, bool overwrite = false) 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); diff --git a/src/NzbDrone.Common/Disk/IDiskProvider.cs b/src/NzbDrone.Common/Disk/IDiskProvider.cs index f98529ead..20f36c67d 100644 --- a/src/NzbDrone.Common/Disk/IDiskProvider.cs +++ b/src/NzbDrone.Common/Disk/IDiskProvider.cs @@ -28,6 +28,7 @@ public interface IDiskProvider 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); diff --git a/src/NzbDrone.Core/Tv/MoveSeriesService.cs b/src/NzbDrone.Core/Tv/MoveSeriesService.cs index 75769f7ec..6797a1529 100644 --- a/src/NzbDrone.Core/Tv/MoveSeriesService.cs +++ b/src/NzbDrone.Core/Tv/MoveSeriesService.cs @@ -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 @@ public class MoveSeriesService : IExecute, IExecute