From a16b950ab1922af7ff85ed542f68d10fd738e94d Mon Sep 17 00:00:00 2001 From: MrFry Date: Sun, 10 Nov 2019 15:56:43 +0100 Subject: [PATCH] Checking if file exists before streaming --- modules/stuff.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/stuff.js b/modules/stuff.js index 8b95381..4b3527e 100644 --- a/modules/stuff.js +++ b/modules/stuff.js @@ -60,6 +60,13 @@ function appGetFileType (app, wildcard, contentType, pageToRender) { fp = fp.join('/') } const fpath = './public/files' + fp + if (!fs.existsSync(fpath)) { + res.render('stuff/nofile', { + missingFile: fpath, + url + }) + return + } if (req.query.stream || !pageToRender) { const stat = fs.statSync(fpath) const fileSize = stat.size