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
818 B
27 lines
818 B
using NzbDrone.Core.Datastore;
|
|
|
|
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
|
{
|
|
public class CleanupOrphanedTrackFiles : IHousekeepingTask
|
|
{
|
|
private readonly IMainDatabase _database;
|
|
|
|
public CleanupOrphanedTrackFiles(IMainDatabase database)
|
|
{
|
|
_database = database;
|
|
}
|
|
|
|
public void Clean()
|
|
{
|
|
var mapper = _database.GetDataMapper();
|
|
|
|
mapper.ExecuteNonQuery(@"DELETE FROM TrackFiles
|
|
WHERE Id IN (
|
|
SELECT TrackFiles.Id FROM TrackFiles
|
|
LEFT OUTER JOIN Tracks
|
|
ON TrackFiles.Id = Tracks.TrackFileId
|
|
WHERE Tracks.Id IS NULL)");
|
|
}
|
|
}
|
|
}
|