From 803c2dd66b97806a28a3ec93a9924c52bbb4906c Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 5 Dec 2023 16:30:38 +0200 Subject: [PATCH] Fixed: Avoid lookups for empty MusicBrainz IDs in import list fetching --- src/NzbDrone.Core/ImportLists/ImportListSyncService.cs | 4 ++-- src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs b/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs index fa7c11b6b..80085e095 100644 --- a/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs +++ b/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs @@ -163,7 +163,7 @@ namespace NzbDrone.Core.ImportLists private void ProcessAlbumReport(ImportListDefinition importList, ImportListItemInfo report, Dictionary listExclusions, List albumsToAdd, List artistsToAdd) { - if (report.AlbumMusicBrainzId == null || report.ArtistMusicBrainzId == null) + if (report.AlbumMusicBrainzId.IsNullOrWhiteSpace() || report.ArtistMusicBrainzId.IsNullOrWhiteSpace()) { return; } @@ -267,7 +267,7 @@ namespace NzbDrone.Core.ImportLists private Artist ProcessArtistReport(ImportListDefinition importList, ImportListItemInfo report, Dictionary listExclusions, List artistsToAdd) { - if (report.ArtistMusicBrainzId == null) + if (report.ArtistMusicBrainzId.IsNullOrWhiteSpace()) { return null; } diff --git a/src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs b/src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs index 214c0bf0a..f38056a36 100644 --- a/src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs +++ b/src/NzbDrone.Core/Music/Repositories/ArtistRepository.cs @@ -47,11 +47,9 @@ namespace NzbDrone.Core.Music public Artist FindById(string foreignArtistId) { - Artist artist; + var artist = Query(Builder().Where(m => m.ForeignArtistId == foreignArtistId)).SingleOrDefault(); - artist = Query(Builder().Where(m => m.ForeignArtistId == foreignArtistId)).SingleOrDefault(); - - if (artist == null) + if (artist == null && foreignArtistId.IsNotNullOrWhiteSpace()) { artist = Query(Builder().Where(x => x.OldForeignArtistIds.Contains(foreignArtistId))).SingleOrDefault(); }