fixed fs.renameSync & docker issue

This commit is contained in:
leca 2024-10-28 22:04:50 +03:00
parent 155faa6731
commit 47e90764e7
2 changed files with 11 additions and 5 deletions

View File

@ -3,9 +3,12 @@ services:
build: .
ports:
- 8012:3000
- 8012:8080
depends_on:
- database
volumes:
- ./data/temp:/temp
- ./data/uploads:/uploads
database:
image: 'postgres:15'

View File

@ -18,8 +18,9 @@ class AbstractProductController {
return res.status(400).send("Only .png files are allowed")
}
fs.renameSync(tempPath, targetPath);
//fs.renameSync(tempPath, targetPath);
fs.copyFileSync(tempPath, targetPath);
fs.rmSync(tempPath);
await AbstractProductService.create(groupId, localId, barcode, name, net_weight, image_filename, category, unit);
return res.status(200).send("Successfull");
} catch (e) {
@ -48,7 +49,9 @@ class AbstractProductController {
if (net_weight) await AbstractProductService.updateNetWeight(groupId, localId, net_weight);
if (image_filename && tempPath) {
fs.renameSync(tempPath, targetPath);
//fs.renameSync(tempPath, targetPath);
fs.copyFileSync(tempPath, targetPath);
fs.rmSync(tempPath);
await AbstractProductService.updateImageFilename(groupId, localId, image_filename);
} else if (image_filename && !tempPath) {
return res.status(400).send("You must supply image file along with its hash");
@ -74,4 +77,4 @@ class AbstractProductController {
}
};
export default new AbstractProductController();
export default new AbstractProductController();