mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
595efd498e
Co-authored-by: ferencmarkizay <ferencmarkizay@gmail.com>
28 lines
968 B
C#
28 lines
968 B
C#
using Dapper;
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
|
{
|
|
public class CleanupOrphanedDownloadClientStatus : IHousekeepingTask
|
|
{
|
|
private readonly IMainDatabase _database;
|
|
|
|
public CleanupOrphanedDownloadClientStatus(IMainDatabase database)
|
|
{
|
|
_database = database;
|
|
}
|
|
|
|
public void Clean()
|
|
{
|
|
using var mapper = _database.OpenConnection();
|
|
|
|
mapper.Execute(@"DELETE FROM ""DownloadClientStatus""
|
|
WHERE ""Id"" IN (
|
|
SELECT ""DownloadClientStatus"".""Id"" FROM ""DownloadClientStatus""
|
|
LEFT OUTER JOIN ""DownloadClients""
|
|
ON ""DownloadClientStatus"".""ProviderId"" = ""DownloadClients"".""Id""
|
|
WHERE ""DownloadClients"".""Id"" IS NULL)");
|
|
}
|
|
}
|
|
}
|