2021-08-04 04:00:28 +00:00
|
|
|
|
using Dapper;
|
|
|
|
|
using NzbDrone.Core.Datastore;
|
2016-06-16 06:53:23 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
|
|
|
|
{
|
|
|
|
|
public class CleanupAbsolutePathMetadataFiles : IHousekeepingTask
|
|
|
|
|
{
|
|
|
|
|
private readonly IMainDatabase _database;
|
|
|
|
|
|
|
|
|
|
public CleanupAbsolutePathMetadataFiles(IMainDatabase database)
|
|
|
|
|
{
|
|
|
|
|
_database = database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Clean()
|
|
|
|
|
{
|
2021-08-04 04:00:28 +00:00
|
|
|
|
using (var mapper = _database.OpenConnection())
|
|
|
|
|
{
|
|
|
|
|
mapper.Execute(@"DELETE FROM MetadataFiles
|
2016-06-16 06:53:23 +00:00
|
|
|
|
WHERE Id IN (
|
|
|
|
|
SELECT Id FROM MetadataFiles
|
|
|
|
|
WHERE RelativePath
|
|
|
|
|
LIKE '_:\%'
|
|
|
|
|
OR RelativePath
|
|
|
|
|
LIKE '\%'
|
|
|
|
|
OR RelativePath
|
|
|
|
|
LIKE '/%'
|
|
|
|
|
)");
|
2021-08-04 04:00:28 +00:00
|
|
|
|
}
|
2016-06-16 06:53:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|