mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-27 01:48:33 +03:00
Reject on dump failure to trigger a retry
This commit is contained in:
@@ -234,11 +234,11 @@ async function queueDump(): Promise<void> {
|
||||
const fileName = `${table.name}_${startTime}.csv`;
|
||||
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}\\"` : ``})`
|
||||
+ ` TO '${file}' WITH (FORMAT CSV, HEADER true);"`, credentials, (error, stdout, stderr) => {
|
||||
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);
|
||||
@@ -253,10 +253,10 @@ async function queueDump(): Promise<void> {
|
||||
latestDumpFiles = [...dumpFiles];
|
||||
|
||||
lastUpdate = startTime;
|
||||
updateQueued = false;
|
||||
} catch(e) {
|
||||
Logger.error(e as string);
|
||||
} finally {
|
||||
updateQueued = false;
|
||||
updateRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user