deleting abstract product image on its deletion

This commit is contained in:
leca 2024-11-13 19:36:55 +03:00
parent 2be40b6f34
commit eb0c8ac99d
2 changed files with 6 additions and 1 deletions

View File

@ -16,7 +16,8 @@ services:
# ports:
# - 5432:5432
volumes:
- ./data/db:/var/lib/postgresql
environment:
POSTGRES_USER: bsfe
POSTGRES_PASSWORD: Ch@NgEME!

View File

@ -93,6 +93,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 });