mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-13 06:57:05 +03:00
Don't update lastUpdate until the update is complete
This commit is contained in:
@@ -187,7 +187,7 @@ function updateQueueTime(): void {
|
|||||||
|
|
||||||
async function queueDump(): Promise<void> {
|
async function queueDump(): Promise<void> {
|
||||||
if (updateQueued && !updateRunning) {
|
if (updateQueued && !updateRunning) {
|
||||||
lastUpdate = Date.now();
|
const startTime = Date.now();
|
||||||
updateRunning = true;
|
updateRunning = true;
|
||||||
|
|
||||||
await removeOutdatedDumps(appExportPath);
|
await removeOutdatedDumps(appExportPath);
|
||||||
@@ -195,7 +195,7 @@ async function queueDump(): Promise<void> {
|
|||||||
const dumpFiles = [];
|
const dumpFiles = [];
|
||||||
|
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
const fileName = `${table.name}_${lastUpdate}.csv`;
|
const fileName = `${table.name}_${startTime}.csv`;
|
||||||
const file = `${postgresExportPath}/${fileName}`;
|
const file = `${postgresExportPath}/${fileName}`;
|
||||||
await db.prepare('run', `COPY (SELECT * FROM "${table.name}"${table.order ? ` ORDER BY "${table.order}"` : ``})
|
await db.prepare('run', `COPY (SELECT * FROM "${table.name}"${table.order ? ` ORDER BY "${table.order}"` : ``})
|
||||||
TO '${file}' WITH (FORMAT CSV, HEADER true);`);
|
TO '${file}' WITH (FORMAT CSV, HEADER true);`);
|
||||||
@@ -208,5 +208,6 @@ async function queueDump(): Promise<void> {
|
|||||||
|
|
||||||
updateQueued = false;
|
updateQueued = false;
|
||||||
updateRunning = false;
|
updateRunning = false;
|
||||||
|
lastUpdate = startTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user