From 0bd3ebaeb40a3d612f3b8fa454d9ab21850614a9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 26 Jul 2020 10:50:11 -0700 Subject: [PATCH] Fixed: Don't create empty artist folder if delete empty folders is enabled Fixes Sonarr/Sonarr#3838 (cherry picked from commit 4f15cd55be5f7332ebde608d8b438384865e9dc1) --- .../MediaFiles/DiskScanService.cs | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs index 0c5c4ca05..a77432497 100644 --- a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -142,6 +142,35 @@ public void Scan(List folders = null, FilterFilesType filter = FilterFil mediaFileList.AddRange(files); } + var artists = _artistService.GetArtists(artistIds); + + // Check for missing artist folders if specific artists are being scanned + if (artistIds != null && artistIds.Any()) + { + foreach (var artist in artists) + { + if (!_diskProvider.FolderExists(artist.Path)) + { + if (_configService.CreateEmptyArtistFolders) + { + if (_configService.DeleteEmptyFolders) + { + _logger.Debug("Not creating missing artist folder: {0} because delete empty folders is enabled", artist.Path); + } + else + { + _logger.Debug("Creating missing artist folder: {0}", artist.Path); + _diskProvider.CreateFolder(artist.Path); + } + } + else + { + _logger.Debug("Artist folder doesn't exist: {0}", artist.Path); + } + } + } + } + musicFilesStopwatch.Stop(); _logger.Trace("Finished getting track files for:\n{0} [{1}]", folders.ConcatToString("\n"), musicFilesStopwatch.Elapsed); @@ -211,7 +240,6 @@ public void Scan(List folders = null, FilterFilesType filter = FilterFil _logger.Debug($"Updated info for {updatedFiles.Count} known files"); - var artists = _artistService.GetArtists(artistIds); foreach (var artist in artists) { CompletedScanning(artist);