From 8968f41b753414e793e0e5fc1af4de5b28ac200d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Tue, 18 Aug 2020 08:10:40 +0200 Subject: [PATCH] Queue changes --- .../item/back/methods/item-image-queue/downloadImages.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index e27b4516a..d6e38d97d 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -20,7 +20,6 @@ module.exports = Self => { const models = Self.app.models; try { - const imageQueue = await Self.find({where: {error: null}, limit: 25}); /* const tempPath = path.join('/tmp/salix-image'); */ const rootPath = models.Image.getPath(); const tempPath = path.join(rootPath, 'temp'); @@ -28,7 +27,8 @@ module.exports = Self => { // Create temporary path await fs.mkdir(tempPath, {recursive: true}); - for (let image of imageQueue) { + setInterval(async() => { + const image = await Self.findOne({where: {error: null}}); const fileName = `${image.itemFk}.png`; const filePath = path.join(tempPath, fileName); const file = fs.createWriteStream(filePath); @@ -58,7 +58,7 @@ module.exports = Self => { }).on('error', async error => { await errorHandler(image.itemFk, error, filePath); }); - } + }, 500); } catch (error) { await errorHandler(image.itemFk, error); }