diff --git a/lib/note/noteActions.js b/lib/note/noteActions.js index 90f23f69..31f7c1f4 100644 --- a/lib/note/noteActions.js +++ b/lib/note/noteActions.js @@ -95,8 +95,11 @@ function actionPDF (req, res, note) { res.setHeader('Cache-Control', 'private') res.setHeader('Content-Type', 'application/pdf; charset=UTF-8') res.setHeader('X-Robots-Tag', 'noindex, nofollow') // prevent crawling + stream.on('end', () => { + stream.close() + fs.unlinkSync(pdfPath) + }) stream.pipe(res) - fs.unlinkSync(pdfPath) }) }