From 211ecf700be016214678e8c1a398843eec53cd17 Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 28 Dec 2023 18:23:41 -0500 Subject: [PATCH] Reject on dump failure to trigger a retry --- src/routes/dumpDatabase.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/dumpDatabase.ts b/src/routes/dumpDatabase.ts index dfbf006..7f4b3ba 100644 --- a/src/routes/dumpDatabase.ts +++ b/src/routes/dumpDatabase.ts @@ -234,11 +234,11 @@ async function queueDump(): Promise { const fileName = `${table.name}_${startTime}.csv`; const file = `${appExportPath}/${fileName}`; - await new Promise((resolve) => { + await new Promise((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 { latestDumpFiles = [...dumpFiles]; lastUpdate = startTime; + updateQueued = false; } catch(e) { Logger.error(e as string); } finally { - updateQueued = false; updateRunning = false; } }