UI Updates (Cancel Import, Move Artist, Manual Import from Artist)

Ability to cancel an import lookup/search at any point.
Ability to move artist path from Artist Edit or bulk move from Mass Editor.
Trigger manual import for Artist path from Artist Detail page.
Pulled from Sonarr
This commit is contained in:
Qstick
2017-12-29 22:23:04 -05:00
parent 5fae202760
commit d8c89f5bbd
79 changed files with 1075 additions and 376 deletions
+40 -23
View File
@@ -1,7 +1,6 @@
using System.IO;
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;
@@ -11,7 +10,7 @@ using NzbDrone.Core.Music.Events;
namespace NzbDrone.Core.Music
{
public class MoveArtistService : IExecute<MoveArtistCommand>
public class MoveArtistService : IExecute<MoveArtistCommand>, IExecute<BulkMoveArtistCommand>
{
private readonly IArtistService _artistService;
private readonly IBuildFileNames _filenameBuilder;
@@ -32,38 +31,56 @@ namespace NzbDrone.Core.Music
_logger = logger;
}
public void Execute(MoveArtistCommand message)
private void MoveSingleArtist(Artist artist, string sourcePath, string destinationPath)
{
var artist = _artistService.GetArtist(message.ArtistId);
var source = message.SourcePath;
var destination = message.DestinationPath;
_logger.ProgressInfo("Moving {0} from '{1}' to '{2}'", artist.Name, sourcePath, destinationPath);
if (!message.DestinationRootFolder.IsNullOrWhiteSpace())
{
_logger.Debug("Buiding destination path using root folder: {0} and the artist name", message.DestinationRootFolder);
destination = Path.Combine(message.DestinationRootFolder, _filenameBuilder.GetArtistFolder(artist));
}
_logger.ProgressInfo("Moving {0} from '{1}' to '{2}'", artist.Name, source, destination);
//TODO: Move to transactional disk operations
try
{
_diskTransferService.TransferFolder(source, destination, TransferMode.Move);
_diskTransferService.TransferFolder(sourcePath, destinationPath, TransferMode.Move);
}
catch (IOException ex)
{
_logger.Error(ex, "Unable to move artist from '{0}' to '{1}'", source, destination);
throw;
_logger.Error(ex, "Unable to move artist from '{0}' to '{1}'. Try moving files manually", sourcePath, destinationPath);
RevertPath(artist.Id, sourcePath);
}
_logger.ProgressInfo("{0} moved successfully to {1}", artist.Name, artist.Path);
//Update the artist path to the new path
artist.Path = destination;
artist = _artistService.UpdateArtist(artist);
_eventAggregator.PublishEvent(new ArtistMovedEvent(artist, sourcePath, destinationPath));
}
_eventAggregator.PublishEvent(new ArtistMovedEvent(artist, source, destination));
private void RevertPath(int artistId, string path)
{
var artist = _artistService.GetArtist(artistId);
artist.Path = path;
_artistService.UpdateArtist(artist);
}
public void Execute(MoveArtistCommand message)
{
var artist = _artistService.GetArtist(message.ArtistId);
MoveSingleArtist(artist, message.SourcePath, message.DestinationPath);
}
public void Execute(BulkMoveArtistCommand message)
{
var artistToMove = message.Artist;
var destinationRootFolder = message.DestinationRootFolder;
_logger.ProgressInfo("Moving {0} artist to '{1}'", artistToMove.Count, destinationRootFolder);
foreach (var s in artistToMove)
{
var artist = _artistService.GetArtist(s.ArtistId);
var destinationPath = Path.Combine(destinationRootFolder, _filenameBuilder.GetArtistFolder(artist));
MoveSingleArtist(artist, s.SourcePath, destinationPath);
}
_logger.ProgressInfo("Finished moving {0} artist to '{1}'", artistToMove.Count, destinationRootFolder);
}
}
}