diff --git a/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs b/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs index 2e5d64571..342697b92 100644 --- a/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs +++ b/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using NzbDrone.Core.Music; using System.Data; using System; +using System.Linq; +using NzbDrone.Common.Extensions; namespace NzbDrone.Core.Datastore.Migration { @@ -158,7 +160,8 @@ namespace NzbDrone.Core.Datastore.Migration private void PopulateReleases(IDbConnection conn, IDbTransaction tran) { var releases = ReadReleasesFromAlbums(conn, tran); - WriteReleasesToReleases(releases,conn, tran); + var dupeFreeReleases = releases.DistinctBy(x => x.ForeignReleaseId).ToList(); + WriteReleasesToReleases(dupeFreeReleases, conn, tran); } public class LegacyAlbumRelease : IEmbeddedDocument @@ -200,7 +203,7 @@ namespace NzbDrone.Core.Datastore.Migration releases.Add(new AlbumRelease { AlbumId = rgId, ForeignReleaseId = albumRelease.Id, - Title = albumRelease.Title, + Title = albumRelease.Title.IsNotNullOrWhiteSpace() ? albumRelease.Title : "", Status = "", Duration = 0, Label = albumRelease.Label, diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedArtistMetadata.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedArtistMetadata.cs index e667e3456..f9992746c 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedArtistMetadata.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedArtistMetadata.cs @@ -20,7 +20,8 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers SELECT ArtistMetadata.Id FROM ArtistMetadata LEFT OUTER JOIN Albums ON Albums.ArtistMetadataId = ArtistMetadata.Id LEFT OUTER JOIN Tracks ON Tracks.ArtistMetadataId = ArtistMetadata.Id - WHERE Albums.Id IS NULL AND Tracks.Id IS NULL)"); + LEFT OUTER JOIN Artists ON Artists.ArtistMetadataId = ArtistMetadata.Id + WHERE Albums.Id IS NULL AND Tracks.Id IS NULL AND Artists.Id IS NULL)"); } } } diff --git a/src/NzbDrone.Core/Music/RefreshAlbumService.cs b/src/NzbDrone.Core/Music/RefreshAlbumService.cs index b66b9e2ec..13996c496 100644 --- a/src/NzbDrone.Core/Music/RefreshAlbumService.cs +++ b/src/NzbDrone.Core/Music/RefreshAlbumService.cs @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Music album.AlbumReleases = new List(); var remoteReleases = albumInfo.AlbumReleases.Value.DistinctBy(m => m.ForeignReleaseId).ToList(); - var existingReleases = _releaseService.GetReleasesByForeignReleaseId(remoteReleases.Select(x => x.ForeignReleaseId).ToList()); + var existingReleases = _releaseService.GetReleasesByAlbum(album.Id); var newReleaseList = new List(); var updateReleaseList = new List();