Fix housekeepers

pull/33/head
ta264 5 years ago
parent 307989aab7
commit 2cb54cdc83

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
{ {
DeleteDuplicateArtistMetadata(); DeleteDuplicateArtistMetadata();
DeleteDuplicateBookMetadata(); DeleteDuplicateBookMetadata();
DeleteDuplicateBookImages(); DeleteDuplicateBookFileMetadata();
} }
private void DeleteDuplicateArtistMetadata() private void DeleteDuplicateArtistMetadata()
@ -40,21 +40,21 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
mapper.Execute(@"DELETE FROM MetadataFiles mapper.Execute(@"DELETE FROM MetadataFiles
WHERE Id IN ( WHERE Id IN (
SELECT Id FROM MetadataFiles SELECT Id FROM MetadataFiles
WHERE Type = 2 WHERE Type IN (2, 4)
GROUP BY BookFileId, Consumer GROUP BY BookId, Consumer
HAVING COUNT(BookFileId) > 1 HAVING COUNT(BookId) > 1
)"); )");
} }
} }
private void DeleteDuplicateBookImages() private void DeleteDuplicateBookFileMetadata()
{ {
using (var mapper = _database.OpenConnection()) using (var mapper = _database.OpenConnection())
{ {
mapper.Execute(@"DELETE FROM MetadataFiles mapper.Execute(@"DELETE FROM MetadataFiles
WHERE Id IN ( WHERE Id IN (
SELECT Id FROM MetadataFiles SELECT Id FROM MetadataFiles
WHERE Type = 4 WHERE Type IN (2, 4)
GROUP BY BookFileId, Consumer GROUP BY BookFileId, Consumer
HAVING COUNT(BookFileId) > 1 HAVING COUNT(BookFileId) > 1
)"); )");

@ -69,7 +69,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
mapper.Execute(@"DELETE FROM MetadataFiles mapper.Execute(@"DELETE FROM MetadataFiles
WHERE Id IN ( WHERE Id IN (
SELECT Id FROM MetadataFiles SELECT Id FROM MetadataFiles
WHERE Type IN (4, 6) WHERE Type IN (2, 4)
AND BookId = 0)"); AND BookId = 0)");
} }
} }
@ -81,7 +81,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
mapper.Execute(@"DELETE FROM MetadataFiles mapper.Execute(@"DELETE FROM MetadataFiles
WHERE Id IN ( WHERE Id IN (
SELECT Id FROM MetadataFiles SELECT Id FROM MetadataFiles
WHERE Type IN (2, 5) WHERE Type IN (2, 4)
AND BookFileId = 0)"); AND BookFileId = 0)");
} }
} }

Loading…
Cancel
Save