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