mirror of https://github.com/status-im/codimd.git
fix: download pdf twice may crash server
Signed-off-by: BoHong Li <raccoon@hackmd.io>
This commit is contained in:
parent
90898e700f
commit
b8fb9dbb9e
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue