Fixed: Correctly delete trackfiles on AlbumDeletedEvent

GetFilesByAlbum performs a join on the album releases under the hood,
which won't be populated once the album is deleted.  Fix by providing
a special delete method which omits the join and just looks at albumId.
This commit is contained in:
ta264
2019-06-26 21:57:31 +01:00
parent 3ebbf6ff83
commit 447bf63a4d
3 changed files with 18 additions and 2 deletions
@@ -6,6 +6,7 @@ using NzbDrone.Core.Qualities;
using NzbDrone.Core.Music;
using NzbDrone.Core.Test.Framework;
using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Core.Test.MediaFiles
{
@@ -140,5 +141,14 @@ namespace NzbDrone.Core.Test.MediaFiles
file.Artist.Value.Metadata.Value.Should().NotBeNull();
}
}
[Test]
public void delete_files_by_album_should_work_if_join_fails()
{
Db.Delete(album);
Subject.DeleteFilesByAlbum(album.Id);
Db.All<TrackFile>().Where(x => x.AlbumId == album.Id).Should().HaveCount(0);
}
}
}