fix(invoice): fixed pdf generation condition race
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
54fa419255
commit
26df12a70a
|
@ -75,16 +75,11 @@ module.exports = Self => {
|
|||
if (tx) await tx.commit();
|
||||
|
||||
const writeStream = fs.createWriteStream(fileSrc);
|
||||
writeStream.on('open', () => {
|
||||
response.pipe(writeStream);
|
||||
});
|
||||
writeStream.on('open', () => response.pipe(writeStream));
|
||||
writeStream.on('finish', () => writeStream.end());
|
||||
|
||||
return new Promise(resolve => {
|
||||
writeStream.on('finish', () => {
|
||||
writeStream.end();
|
||||
|
||||
resolve(invoiceOut);
|
||||
});
|
||||
writeStream.on('close', () => resolve(invoiceOut));
|
||||
});
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
|
|
|
@ -70,7 +70,6 @@ module.exports = Self => {
|
|||
let stream = fs.createReadStream(file.path);
|
||||
return [stream, file.contentType, `filename="${file.name}"`];
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
if (error.code === 'ENOENT')
|
||||
throw new UserError('The PDF document does not exists');
|
||||
|
||||
|
|
Loading…
Reference in New Issue