Merge branch 'dev' into 2394-order_index_total
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
8b67c6f1a5
|
@ -90,7 +90,9 @@ module.exports = Self => {
|
|||
);
|
||||
}
|
||||
|
||||
if (fs.existsSync(srcFilePath))
|
||||
await fs.unlink(srcFilePath);
|
||||
|
||||
await tx.commit();
|
||||
return newImage;
|
||||
} catch (e) {
|
||||
|
|
|
@ -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);
|
||||
}, 1000);
|
||||
} 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;
|
||||
} catch (err) {
|
||||
throw new Error(`ErrorHandler error: ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue