mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Merge pull request #248 from MRuy/feature/add-version-to-databasejson
Add version to database.json
This commit is contained in:
commit
87c6dab41d
1 changed files with 8 additions and 1 deletions
|
@ -143,6 +143,7 @@ export default async function dumpDatabase(req: Request, res: Response, showPage
|
|||
${updateQueued ? `Update queued.` : ``} Last updated: ${lastUpdate ? new Date(lastUpdate).toUTCString() : `Unknown`}`);
|
||||
} else {
|
||||
res.send({
|
||||
dbVersion: await getDbVersion(),
|
||||
lastUpdated: lastUpdate,
|
||||
updateQueued,
|
||||
links: latestDumpFiles.map((item:any) => {
|
||||
|
@ -158,6 +159,12 @@ export default async function dumpDatabase(req: Request, res: Response, showPage
|
|||
await queueDump();
|
||||
}
|
||||
|
||||
async function getDbVersion(): Promise<number> {
|
||||
const row = await db.prepare('get', `SELECT "value" FROM "config" WHERE "key" = 'version'`);
|
||||
if (row === undefined) return 0;
|
||||
return row.value;
|
||||
}
|
||||
|
||||
export async function redirectLink(req: Request, res: Response): Promise<void> {
|
||||
if (!config?.dumpDatabase?.enabled) {
|
||||
res.status(404).send("Database dump is disabled");
|
||||
|
@ -210,4 +217,4 @@ async function queueDump(): Promise<void> {
|
|||
updateRunning = false;
|
||||
lastUpdate = startTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue