Queue changes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-08-18 08:10:40 +02:00
parent a10e091b62
commit 8968f41b75
1 changed files with 3 additions and 3 deletions

View File

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