From 553e07119d1d7319ccca94a84a22f9fa235070ed Mon Sep 17 00:00:00 2001 From: tycrek Date: Thu, 14 Oct 2021 15:57:12 -0600 Subject: [PATCH] Fixed uploads not properly saving to save dir --- src/storage.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/storage.js b/src/storage.js index f5141f9..08fbc79 100644 --- a/src/storage.js +++ b/src/storage.js @@ -113,12 +113,16 @@ function processUploaded(req, res, next) { // skipcq: JS-0045 .catch(reject) )) .then(() => log.debug('File saved', req.file.originalname, s3enabled ? 'in S3' : 'on disk')) - .then(() => !s3enabled && (req.file.path = getLocalFilename(req))) // skipcq: JS-0090 - .then(() => next()) .catch(next) - .finally(() => fs.remove(req.file.path)) + + // Delete the file + .then(() => fs.remove(req.file.path)) .then(() => log.debug('Temp file', 'deleted')) - .catch((err) => log.err(err)); + + // Fix the file path + .then(() => !s3enabled && (req.file.path = getLocalFilename(req))) // skipcq: JS-0090 + .then(() => next()) + .catch(next); } function deleteS3(file) {