From 0655a9aa725c59e9a474af9a8385c6c07825dc07 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 3 Dec 2023 22:16:43 +0200 Subject: [PATCH] Revert "Fixed: Prevent false notification for moving artist when editing" This reverts commit 0133f4331be6bd161deee4b15e6a7c7aa877fa73. --- src/Lidarr.Api.V1/Artist/ArtistController.cs | 22 +++++++++---------- .../Artist/ArtistEditorController.cs | 5 +++-- .../Music/Commands/BulkMoveArtistCommand.cs | 1 + .../Music/Commands/MoveArtistCommand.cs | 1 + .../Music/Services/MoveArtistService.cs | 21 ++++++++++-------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/Lidarr.Api.V1/Artist/ArtistController.cs b/src/Lidarr.Api.V1/Artist/ArtistController.cs index 1e23f2713..41bd3f30f 100644 --- a/src/Lidarr.Api.V1/Artist/ArtistController.cs +++ b/src/Lidarr.Api.V1/Artist/ArtistController.cs @@ -167,19 +167,17 @@ namespace Lidarr.Api.V1.Artist { var artist = _artistService.GetArtist(artistResource.Id); - if (moveFiles) - { - var sourcePath = artist.Path; - var destinationPath = artistResource.Path; + var sourcePath = artist.Path; + var destinationPath = artistResource.Path; - _commandQueueManager.Push(new MoveArtistCommand - { - ArtistId = artist.Id, - SourcePath = sourcePath, - DestinationPath = destinationPath, - Trigger = CommandTrigger.Manual - }); - } + _commandQueueManager.Push(new MoveArtistCommand + { + ArtistId = artist.Id, + SourcePath = sourcePath, + DestinationPath = destinationPath, + MoveFiles = moveFiles, + Trigger = CommandTrigger.Manual + }); var model = artistResource.ToModel(artist); diff --git a/src/Lidarr.Api.V1/Artist/ArtistEditorController.cs b/src/Lidarr.Api.V1/Artist/ArtistEditorController.cs index 75b4510dd..efbaa11e9 100644 --- a/src/Lidarr.Api.V1/Artist/ArtistEditorController.cs +++ b/src/Lidarr.Api.V1/Artist/ArtistEditorController.cs @@ -79,12 +79,13 @@ namespace Lidarr.Api.V1.Artist } } - if (resource.MoveFiles && artistToMove.Any()) + if (artistToMove.Any()) { _commandQueueManager.Push(new BulkMoveArtistCommand { DestinationRootFolder = resource.RootFolderPath, - Artist = artistToMove + Artist = artistToMove, + MoveFiles = resource.MoveFiles }); } diff --git a/src/NzbDrone.Core/Music/Commands/BulkMoveArtistCommand.cs b/src/NzbDrone.Core/Music/Commands/BulkMoveArtistCommand.cs index 8f035792b..23e0e11c7 100644 --- a/src/NzbDrone.Core/Music/Commands/BulkMoveArtistCommand.cs +++ b/src/NzbDrone.Core/Music/Commands/BulkMoveArtistCommand.cs @@ -8,6 +8,7 @@ namespace NzbDrone.Core.Music.Commands { public List Artist { get; set; } public string DestinationRootFolder { get; set; } + public bool MoveFiles { get; set; } public override bool SendUpdatesToClient => true; public override bool RequiresDiskAccess => true; diff --git a/src/NzbDrone.Core/Music/Commands/MoveArtistCommand.cs b/src/NzbDrone.Core/Music/Commands/MoveArtistCommand.cs index c120eddd4..1f46f2f6b 100644 --- a/src/NzbDrone.Core/Music/Commands/MoveArtistCommand.cs +++ b/src/NzbDrone.Core/Music/Commands/MoveArtistCommand.cs @@ -7,6 +7,7 @@ namespace NzbDrone.Core.Music.Commands public int ArtistId { get; set; } public string SourcePath { get; set; } public string DestinationPath { get; set; } + public bool MoveFiles { get; set; } public override bool SendUpdatesToClient => true; public override bool RequiresDiskAccess => true; diff --git a/src/NzbDrone.Core/Music/Services/MoveArtistService.cs b/src/NzbDrone.Core/Music/Services/MoveArtistService.cs index 7441addce..867084001 100644 --- a/src/NzbDrone.Core/Music/Services/MoveArtistService.cs +++ b/src/NzbDrone.Core/Music/Services/MoveArtistService.cs @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Music _logger = logger; } - private void MoveSingleArtist(Artist artist, string sourcePath, string destinationPath, int? index = null, int? total = null) + private void MoveSingleArtist(Artist artist, string sourcePath, string destinationPath, bool moveFiles, int? index = null, int? total = null) { if (!_diskProvider.FolderExists(sourcePath)) { @@ -57,14 +57,17 @@ namespace NzbDrone.Core.Music try { - _rootFolderWatchingService.ReportFileSystemChangeBeginning(sourcePath, destinationPath); + if (moveFiles) + { + _rootFolderWatchingService.ReportFileSystemChangeBeginning(sourcePath, destinationPath); - // Ensure the parent of the artist folder exists, this will often just be the root folder, but - // in cases where people are using subfolders for first letter (etc) it may not yet exist. - _diskProvider.CreateFolder(new DirectoryInfo(destinationPath).Parent.FullName); - _diskTransferService.TransferFolder(sourcePath, destinationPath, TransferMode.Move); + // Ensure the parent of the artist folder exists, this will often just be the root folder, but + // in cases where people are using subfolders for first letter (etc) it may not yet exist. + _diskProvider.CreateFolder(new DirectoryInfo(destinationPath).Parent.FullName); + _diskTransferService.TransferFolder(sourcePath, destinationPath, TransferMode.Move); - _logger.ProgressInfo("{0} moved successfully to {1}", artist.Name, destinationPath); + _logger.ProgressInfo("{0} moved successfully to {1}", artist.Name, destinationPath); + } _eventAggregator.PublishEvent(new ArtistMovedEvent(artist, sourcePath, destinationPath)); } @@ -88,7 +91,7 @@ namespace NzbDrone.Core.Music { var artist = _artistService.GetArtist(message.ArtistId); - MoveSingleArtist(artist, message.SourcePath, message.DestinationPath); + MoveSingleArtist(artist, message.SourcePath, message.DestinationPath, message.MoveFiles); } public void Execute(BulkMoveArtistCommand message) @@ -104,7 +107,7 @@ namespace NzbDrone.Core.Music var artist = _artistService.GetArtist(s.ArtistId); var destinationPath = Path.Combine(destinationRootFolder, _filenameBuilder.GetArtistFolder(artist)); - MoveSingleArtist(artist, s.SourcePath, destinationPath, index, artistToMove.Count); + MoveSingleArtist(artist, s.SourcePath, destinationPath, message.MoveFiles, index, artistToMove.Count); } _logger.ProgressInfo("Finished moving {0} artist to '{1}'", artistToMove.Count, destinationRootFolder);