deleting old image of an abstract product on its update
This commit is contained in:
parent
eb0c8ac99d
commit
3c7e88d389
|
@ -50,6 +50,10 @@ class AbstractProductController {
|
||||||
targetPath = path.join(path.resolve(path.dirname('')) + `/uploads/${image_filename}.png`);
|
targetPath = path.join(path.resolve(path.dirname('')) + `/uploads/${image_filename}.png`);
|
||||||
fs.copyFileSync(tempPath, targetPath);
|
fs.copyFileSync(tempPath, targetPath);
|
||||||
fs.rmSync(tempPath);
|
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);
|
if (barcode) await AbstractProductService.updateBarcode(groupId, localId, barcode);
|
||||||
|
|
Loading…
Reference in New Issue