mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
WIP: Fix migration to DB version 23 (#571)
* Watch out for malformed AlbumReleases in Albums
Don't try to insert if Title is empty and catch and SQLite exceptions.
* Better fix for migration
Filter out null titles and duplicate release ids
Revert "Watch out for malformed AlbumReleases in Albums"
This reverts commit b9f707dc2f
.
* Purge tracks linked to bad albumrelease
* fixup! migration missing titles, releases not in remote, artist cleaning
This commit is contained in:
parent
c392569a63
commit
6723f32abb
3 changed files with 8 additions and 4 deletions
|
@ -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,
|
||||
|
|
|
@ -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)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace NzbDrone.Core.Music
|
|||
album.AlbumReleases = new List<AlbumRelease>();
|
||||
|
||||
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<AlbumRelease>();
|
||||
var updateReleaseList = new List<AlbumRelease>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue