fixed wrong action sequence
This commit is contained in:
parent
9988cedbc4
commit
7d98ba89c5
|
@ -45,15 +45,18 @@ class AbstractProductController {
|
|||
|
||||
if (req.file) {
|
||||
tempPath = req.file.path;
|
||||
|
||||
let previousImageHash = (await AbstractProductService.getByLocalId(groupId, localId)).image_filename
|
||||
let previousImagePath = path.join(path.resolve(path.dirname('')), `/uploads/${previousImageHash}.png`);
|
||||
fs.unlinkSync(previousImagePath)
|
||||
|
||||
image_buffer = fs.readFileSync(tempPath);
|
||||
image_filename = createHash('md5').update(image_buffer).digest('hex');
|
||||
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);
|
||||
|
|
|
@ -32,6 +32,8 @@ app.get('/status', (req, res) => {
|
|||
|
||||
wss.on('connection', (client) => {
|
||||
client.on('message', async (message) => {
|
||||
if (message == "keepalive") return;
|
||||
|
||||
let parsed = JSON.parse(message);
|
||||
let token = parsed.token;
|
||||
let currentGroup = parsed.currentGroup;
|
||||
|
@ -51,7 +53,6 @@ wss.on('connection', (client) => {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
clients.push({
|
||||
socket: client,
|
||||
token,
|
||||
|
@ -62,6 +63,7 @@ wss.on('connection', (client) => {
|
|||
client.on('close', () => {
|
||||
for (let i = 0; i < clients.length; i++) {
|
||||
if (clients[i].socket == client) {
|
||||
log.debug(`Client with token ${clients[i].token} has disconnected`)
|
||||
clients.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue