// Query the database for the ids of duplicate extras
varqueryResult=connection.Query("SELECT t1.Path FROM TypedBaseItems AS t1, TypedBaseItems AS t2 WHERE t1.Path=t2.Path AND t1.Type!=t2.Type AND t1.Type='MediaBrowser.Controller.Entities.Video'");
_logger.LogError(ex,"Cannot make a backup of {Library}",DbFilename);
throw;
}
File.Copy(dbPath,bakPath);
_logger.LogInformation("Library database backed up to {BackupPath}",bakPath);
break;
}
catch(Exceptionex)
{
_logger.LogError(ex,"Cannot make a backup of {Library} at path {BackupPath}",DbFilename,bakPath);
throw;
}
}
_logger.LogInformation("Removing found duplicated extras for the following items: {DuplicateExtras}",bads);
connection.Execute("DELETE FROM TypedBaseItems WHERE rowid IN (SELECT t1.rowid FROM TypedBaseItems AS t1, TypedBaseItems AS t2 WHERE t1.Path=t2.Path AND t1.Type!=t2.Type AND t1.Type='MediaBrowser.Controller.Entities.Video')");
}
// Delete all duplicate extras
_logger.LogInformation("Removing found duplicated extras for the following items: {DuplicateExtras}",bads);
connection.Execute("DELETE FROM TypedBaseItems WHERE rowid IN (SELECT t1.rowid FROM TypedBaseItems AS t1, TypedBaseItems AS t2 WHERE t1.Path=t2.Path AND t1.Type!=t2.Type AND t1.Type='MediaBrowser.Controller.Entities.Video')");