Skip to content

Commit 9e4d165

Browse files
authored
Merge pull request #963 from SISheogorath/fix/crashPDF
Fix server crash on PDF creation
2 parents 32afa14 + 6fdb9ee commit 9e4d165

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/response.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ function actionPDF (req, res, note) {
341341
var path = config.tmpPath + '/' + Date.now() + '.pdf'
342342
content = content.replace(/\]\(\//g, '](' + url + '/')
343343
markdownpdf().from.string(content).to(path, function () {
344+
if (!fs.existsSync(path)) {
345+
logger.error('PDF seems to not be generated as expected. File doesn\'t exist: ' + path)
346+
return response.errorInternalError(res)
347+
}
344348
var stream = fs.createReadStream(path)
345349
var filename = title
346350
// Be careful of special characters

0 commit comments

Comments
 (0)