Fix scope var
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-07-13 14:22:19 +02:00
parent ee19ea2993
commit 838b8a5382
1 changed files with 4 additions and 3 deletions

View File

@ -19,6 +19,7 @@ module.exports = Self => {
Self.download = async() => { Self.download = async() => {
const models = Self.app.models; const models = Self.app.models;
let filePath;
try { try {
const imageQueue = await Self.find({ const imageQueue = await Self.find({
where: { where: {
@ -35,7 +36,7 @@ module.exports = Self => {
for (let image of imageQueue) { for (let image of imageQueue) {
const fileName = `${image.itemFk}.png`; const fileName = `${image.itemFk}.png`;
const filePath = path.join(tempPath, fileName); filePath = path.join(tempPath, fileName);
https.get(image.url, async response => { https.get(image.url, async response => {
// Upload file to temporary path // Upload file to temporary path
@ -46,11 +47,11 @@ module.exports = Self => {
// await image.destroy(); // await image.destroy();
}); });
} }
return imageQueue;
} catch (e) { } catch (e) {
fs.unlink(filePath); fs.unlink(filePath);
throw e; throw e;
} }
return imageQueue;
}; };
}; };