1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2025-01-02 21:15:05 +00:00

Fixed: Manual importing to nested artist folders

This commit is contained in:
Bogdan 2024-10-03 14:47:13 +03:00
parent 3381ffc311
commit 4588bc4a7e

View file

@ -4,6 +4,7 @@
using NLog; using NLog;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.EnsureThat; using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.MediaFiles.TrackImport; using NzbDrone.Core.MediaFiles.TrackImport;
@ -11,6 +12,7 @@
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Organizer; using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Core.MediaFiles namespace NzbDrone.Core.MediaFiles
{ {
@ -31,6 +33,7 @@ public class TrackFileMovingService : IMoveTrackFiles
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IRootFolderWatchingService _rootFolderWatchingService; private readonly IRootFolderWatchingService _rootFolderWatchingService;
private readonly IMediaFileAttributeService _mediaFileAttributeService; private readonly IMediaFileAttributeService _mediaFileAttributeService;
private readonly IRootFolderService _rootFolderService;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly Logger _logger; private readonly Logger _logger;
@ -43,6 +46,7 @@ public TrackFileMovingService(ITrackService trackService,
IDiskProvider diskProvider, IDiskProvider diskProvider,
IRootFolderWatchingService rootFolderWatchingService, IRootFolderWatchingService rootFolderWatchingService,
IMediaFileAttributeService mediaFileAttributeService, IMediaFileAttributeService mediaFileAttributeService,
IRootFolderService rootFolderService,
IEventAggregator eventAggregator, IEventAggregator eventAggregator,
IConfigService configService, IConfigService configService,
Logger logger) Logger logger)
@ -55,6 +59,7 @@ public TrackFileMovingService(ITrackService trackService,
_diskProvider = diskProvider; _diskProvider = diskProvider;
_rootFolderWatchingService = rootFolderWatchingService; _rootFolderWatchingService = rootFolderWatchingService;
_mediaFileAttributeService = mediaFileAttributeService; _mediaFileAttributeService = mediaFileAttributeService;
_rootFolderService = rootFolderService;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_configService = configService; _configService = configService;
_logger = logger; _logger = logger;
@ -148,11 +153,16 @@ private void EnsureTrackFolder(TrackFile trackFile, Artist artist, Album album,
{ {
var trackFolder = Path.GetDirectoryName(filePath); var trackFolder = Path.GetDirectoryName(filePath);
var artistFolder = artist.Path; var artistFolder = artist.Path;
var rootFolder = new OsPath(artistFolder).Directory.FullPath; var rootFolder = _rootFolderService.GetBestRootFolder(artistFolder);
if (!_diskProvider.FolderExists(rootFolder)) if (rootFolder == null || rootFolder.Path.IsNullOrWhiteSpace())
{ {
throw new RootFolderNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder)); throw new RootFolderNotFoundException($"Root folder was not found, '{artistFolder}' is not a subdirectory of a defined root folder.");
}
if (!_diskProvider.FolderExists(rootFolder.Path))
{
throw new RootFolderNotFoundException($"Root folder '{rootFolder.Path}' was not found.");
} }
var changed = false; var changed = false;