You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
841 B
27 lines
841 B
using NzbDrone.Core.Datastore;
|
|
|
|
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
|
{
|
|
public class CleanupOrphanedEpisodeFiles : IHousekeepingTask
|
|
{
|
|
private readonly IMainDatabase _database;
|
|
|
|
public CleanupOrphanedEpisodeFiles(IMainDatabase database)
|
|
{
|
|
_database = database;
|
|
}
|
|
|
|
public void Clean()
|
|
{
|
|
var mapper = _database.GetDataMapper();
|
|
|
|
mapper.ExecuteNonQuery(@"DELETE FROM EpisodeFiles
|
|
WHERE Id IN (
|
|
SELECT EpisodeFiles.Id FROM EpisodeFiles
|
|
LEFT OUTER JOIN Episodes
|
|
ON EpisodeFiles.Id = Episodes.EpisodeFileId
|
|
WHERE Episodes.Id IS NULL)");
|
|
}
|
|
}
|
|
}
|