Compare commits

...

2 Commits

2 changed files with 10 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

@ -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 });