diff --git a/src/controllers/abstractproduct.js b/src/controllers/abstractproduct.js index 94401a9..015d6fb 100644 --- a/src/controllers/abstractproduct.js +++ b/src/controllers/abstractproduct.js @@ -50,6 +50,10 @@ class AbstractProductController { targetPath = path.join(path.resolve(path.dirname('')) + `/uploads/${image_filename}.png`); fs.copyFileSync(tempPath, targetPath); fs.rmSync(tempPath); + + let previousImageHash = (await AbstractProductService.getByLocalId(groupId, localId)).image_filename + let previousImagePath = path.join(path.resolve(path.dirname('')), `/uploads/${previousImageHash}.png`); + fs.unlinkSync(previousImagePath) } if (barcode) await AbstractProductService.updateBarcode(groupId, localId, barcode);