From 30a4bbfe1acd83e1ba7579d28c9adb9a643d1d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Wed, 26 Aug 2020 12:41:38 +0200 Subject: [PATCH 1/6] Css changes --- modules/ticket/front/sale/index.html | 5 ++--- modules/ticket/front/sale/style.scss | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 8caa2f89e..ab3277e31 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -58,7 +58,7 @@ - Id + Id Quantity Item Price @@ -102,9 +102,8 @@ ng-click="descriptor.show($event, sale.itemFk, sale.id)"> {{sale.itemFk}} - Date: Thu, 27 Aug 2020 13:53:11 +0200 Subject: [PATCH 2/6] Changes --- back/models/image.js | 4 +++- .../back/methods/item-image-queue/downloadImages.js | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/back/models/image.js b/back/models/image.js index 340b2e5a6..313e4492b 100644 --- a/back/models/image.js +++ b/back/models/image.js @@ -90,7 +90,9 @@ module.exports = Self => { ); } - await fs.unlink(srcFilePath); + if (fs.existsSync(filePath)) + await fs.unlink(srcFilePath); + await tx.commit(); return newImage; } catch (e) { diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index c49cb0702..d3fd739cc 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -19,7 +19,6 @@ module.exports = Self => { Self.downloadImages = async() => { const models = Self.app.models; - let image; try { const tempPath = path.join('/tmp/salix-image'); @@ -27,7 +26,7 @@ module.exports = Self => { await fs.mkdir(tempPath, {recursive: true}); const timer = setInterval(async() => { - image = await Self.findOne({where: {error: null}}); + const image = await Self.findOne({where: {error: null}}); // Exit loop if (!image) return clearInterval(timer); @@ -62,9 +61,9 @@ module.exports = Self => { await errorHandler(image.itemFk, error, filePath); } }); - }, 1500); + }, 2500); } catch (error) { - await errorHandler(image.itemFk, error); + throw new Error('Try-catch error: ', error); } async function errorHandler(rowId, error, filePath) { @@ -76,10 +75,10 @@ module.exports = Self => { await row.updateAttribute('error', error); - if (filePath) + if (filePath && fs.existsSync(filePath)) await fs.unlink(filePath); } catch (error) { - throw error; + throw new Error('ErrorHandler error: ', error); } } }; From 0c4939830bd27897ed44217b0628c1900900141f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Thu, 27 Aug 2020 14:00:40 +0200 Subject: [PATCH 3/6] Fixed error --- back/models/image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/models/image.js b/back/models/image.js index 313e4492b..113bc7084 100644 --- a/back/models/image.js +++ b/back/models/image.js @@ -90,7 +90,7 @@ module.exports = Self => { ); } - if (fs.existsSync(filePath)) + if (fs.existsSync(srcFilePath)) await fs.unlink(srcFilePath); await tx.commit(); From fd67a85fe8bdcae4c14bb849b61d91cfd9398858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Thu, 27 Aug 2020 14:09:21 +0200 Subject: [PATCH 4/6] Changed to 1 second --- modules/item/back/methods/item-image-queue/downloadImages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index d3fd739cc..febd0289d 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -61,7 +61,7 @@ module.exports = Self => { await errorHandler(image.itemFk, error, filePath); } }); - }, 2500); + }, 1000); } catch (error) { throw new Error('Try-catch error: ', error); } From 55d047c0dd40d61b3cdb6f188cc9c1f7940c5cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Thu, 27 Aug 2020 14:11:22 +0200 Subject: [PATCH 5/6] Renamed error var --- modules/item/back/methods/item-image-queue/downloadImages.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index febd0289d..71af07265 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -77,8 +77,8 @@ module.exports = Self => { if (filePath && fs.existsSync(filePath)) await fs.unlink(filePath); - } catch (error) { - throw new Error('ErrorHandler error: ', error); + } catch (err) { + throw new Error('ErrorHandler error: ', err); } } }; From a75938b6d07196126cc2f5eefd74862114df5006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Thu, 27 Aug 2020 14:23:40 +0200 Subject: [PATCH 6/6] Updated error handler --- modules/item/back/methods/item-image-queue/downloadImages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index 71af07265..420b357a5 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -78,7 +78,7 @@ module.exports = Self => { if (filePath && fs.existsSync(filePath)) await fs.unlink(filePath); } catch (err) { - throw new Error('ErrorHandler error: ', err); + throw new Error(`ErrorHandler error: ${err}`); } } };