mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-09-19 20:51:19 +02:00
Reject on dump failure to trigger a retry
This commit is contained in:
parent
134e89af00
commit
211ecf700b
1 changed files with 3 additions and 3 deletions
|
@ -234,11 +234,11 @@ async function queueDump(): Promise<void> {
|
||||||
const fileName = `${table.name}_${startTime}.csv`;
|
const fileName = `${table.name}_${startTime}.csv`;
|
||||||
const file = `${appExportPath}/${fileName}`;
|
const file = `${appExportPath}/${fileName}`;
|
||||||
|
|
||||||
await new Promise<string>((resolve) => {
|
await new Promise<string>((resolve, reject) => {
|
||||||
exec(`psql -c "\\copy (SELECT * FROM \\"${table.name}\\"${table.order ? ` ORDER BY \\"${table.order}\\"` : ``})`
|
exec(`psql -c "\\copy (SELECT * FROM \\"${table.name}\\"${table.order ? ` ORDER BY \\"${table.order}\\"` : ``})`
|
||||||
+ ` TO '${file}' WITH (FORMAT CSV, HEADER true);"`, credentials, (error, stdout, stderr) => {
|
+ ` TO '${file}' WITH (FORMAT CSV, HEADER true);"`, credentials, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
Logger.error(`[dumpDatabase] Failed to dump ${table.name} to ${file} due to ${stderr}`);
|
reject(`[dumpDatabase] Failed to dump ${table.name} to ${file} due to ${stderr}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(error ? stderr : stdout);
|
resolve(error ? stderr : stdout);
|
||||||
|
@ -253,10 +253,10 @@ async function queueDump(): Promise<void> {
|
||||||
latestDumpFiles = [...dumpFiles];
|
latestDumpFiles = [...dumpFiles];
|
||||||
|
|
||||||
lastUpdate = startTime;
|
lastUpdate = startTime;
|
||||||
|
updateQueued = false;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
Logger.error(e as string);
|
Logger.error(e as string);
|
||||||
} finally {
|
} finally {
|
||||||
updateQueued = false;
|
|
||||||
updateRunning = false;
|
updateRunning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue