From 726b2d5eb2cac2aa9887026f0512d46c76d715ee Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 5 Oct 2022 13:26:18 +0200 Subject: [PATCH] Exit on completion --- back/tests.js | 3 ++- modules/invoiceOut/back/methods/invoiceOut/download.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/back/tests.js b/back/tests.js index 38dcc6384..725aec6e4 100644 --- a/back/tests.js +++ b/back/tests.js @@ -60,7 +60,8 @@ async function test() { helpers: [], }); - jasmine.exitOnCompletion = false; + if (!isCI) jasmine.exitOnCompletion = false; + await jasmine.execute(); if (app) await app.disconnect(); if (container) await container.rm(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index 19dea5b1a..74f5c95fe 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -62,8 +62,14 @@ module.exports = Self => { name: fileName }; - await fs.access(file.path); - let stream = fs.createReadStream(file.path); + try { + await fs.access(file.path); + } catch (error) { + await Self.createPdf(ctx, id); + } + + const stream = fs.createReadStream(file.path); + return [stream, file.contentType, `filename="${file.name}"`]; } catch (error) { if (error.code === 'ENOENT')