Compare commits
2 Commits
2be40b6f34
...
3c7e88d389
Author | SHA1 | Date |
---|---|---|
leca | 3c7e88d389 | |
leca | eb0c8ac99d |
|
@ -16,7 +16,8 @@ services:
|
|||
|
||||
# ports:
|
||||
# - 5432:5432
|
||||
|
||||
volumes:
|
||||
- ./data/db:/var/lib/postgresql
|
||||
environment:
|
||||
POSTGRES_USER: bsfe
|
||||
POSTGRES_PASSWORD: Ch@NgEME!
|
||||
|
|
|
@ -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);
|
||||
|
@ -93,6 +97,10 @@ class AbstractProductController {
|
|||
async delete(req, res) {
|
||||
let { localId, groupId } = req.params;
|
||||
|
||||
let imageFilename = (await AbstractProductService.getByLocalId(groupId, localId)).image_filename
|
||||
let imagePath = path.join(path.resolve(path.dirname('')), `/uploads/${imageFilename}.png`);
|
||||
fs.unlinkSync(imagePath)
|
||||
|
||||
await AbstractProductService.delete(groupId, localId)
|
||||
|
||||
notify(req.headers.authorization.split(' ')[1], groupId, 'delete', 'abstractproduct', { local_id: localId });
|
||||
|
|
Loading…
Reference in New Issue