mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-23 22:40:54 +00:00
Fixed: PG Issues on CleanupOrphanedTrackFiles Housekeeper
This commit is contained in:
parent
83d618e0b7
commit
250a70328e
1 changed files with 12 additions and 0 deletions
|
@ -13,6 +13,12 @@ public CleanupOrphanedTrackFiles(IMainDatabase database)
|
|||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
CleanupOrphanedByAlbum();
|
||||
CleanupOrphanedByTracks();
|
||||
}
|
||||
|
||||
private void CleanupOrphanedByAlbum()
|
||||
{
|
||||
using (var mapper = _database.OpenConnection())
|
||||
{
|
||||
|
@ -24,7 +30,13 @@ public void Clean()
|
|||
LEFT OUTER JOIN ""Tracks""
|
||||
ON ""TrackFiles"".""Id"" = ""Tracks"".""TrackFileId""
|
||||
WHERE ""Tracks"".""Id"" IS NULL)");
|
||||
}
|
||||
}
|
||||
|
||||
private void CleanupOrphanedByTracks()
|
||||
{
|
||||
using (var mapper = _database.OpenConnection())
|
||||
{
|
||||
// Unlink Tracks where the Trackfiles entry no longer exists
|
||||
mapper.Execute(@"UPDATE ""Tracks""
|
||||
SET ""TrackFileId"" = 0
|
||||
|
|
Loading…
Reference in a new issue