From 63bea8a6ef52aac31b6664f31be7044a2e322a2c Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Thu, 24 Feb 2022 15:53:52 -0600 Subject: Allow csv to be downloaded even if the program exits with an error Signed-off-by: Matt Strapp --- src/routes/api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/routes/api.ts b/src/routes/api.ts index fd1ee38..ee80ea5 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -133,10 +133,10 @@ api.route('/actuate') stderr += `STDERR: ${data.toString()}`; }); actuation.on('close', (code: number) => { + const filename: string = (req.body.file.path as string).split('/').pop() as string; // Make sure the program exited with a code of 0 (success) if (code !== 0) - return res.status(500).json({ error: `Program exited with exit code ${code}`, error_msg: stderr }); - const filename: string = (req.body.file.path as string).split('/').pop() as string; + return res.status(500).json({ error: `Program exited with exit code ${code}`, error_msg: stderr, file: { name: req.body.file.file, filename: filename } }); return res.status(200).json({ file: { name: req.body.file.file, filename: filename } }); }); // Kill the process if it takes too long -- cgit v1.2.3