From 30f4cf1f7b35f0a2567897bcce64ed281d636134 Mon Sep 17 00:00:00 2001 From: Keith Valin Date: Fri, 17 Jul 2020 12:21:54 -0400 Subject: [PATCH] Fixing a issue where a image cannot be moved across different partitions --- apiv1/controllers/ImageController.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apiv1/controllers/ImageController.js b/apiv1/controllers/ImageController.js index ffbcc701..57981ce1 100644 --- a/apiv1/controllers/ImageController.js +++ b/apiv1/controllers/ImageController.js @@ -208,10 +208,12 @@ module.exports = { cleanup(file.path); return; } - fs.renameSync(file.path, `${imgDest}/${id}.jpg`); - res.status(201).json({ - message: "Created" - }); + if(createImage(req.body.data, `${imgDest}/${id}.jpg`)) { + res.status(201).json({ + message: "Created" + }); + } + cleanup(file.path); }else if(file){ cleanup(file.path); } @@ -259,8 +261,10 @@ module.exports = { cleanup(file.path); return; } - fs.renameSync(file.path, `${imgDest}/${id}.jpg`); - resp.status(204).send(); + if(createImage(req.body.data, `${imgDest}/${id}.jpg`)) { + resp.status(204).send(); + } + cleanup(file.path); }else if(file){ cleanup(file.path); }