mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Checking if file exists before streaming
This commit is contained in:
@@ -60,6 +60,13 @@ function appGetFileType (app, wildcard, contentType, pageToRender) {
|
|||||||
fp = fp.join('/')
|
fp = fp.join('/')
|
||||||
}
|
}
|
||||||
const fpath = './public/files' + fp
|
const fpath = './public/files' + fp
|
||||||
|
if (!fs.existsSync(fpath)) {
|
||||||
|
res.render('stuff/nofile', {
|
||||||
|
missingFile: fpath,
|
||||||
|
url
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
if (req.query.stream || !pageToRender) {
|
if (req.query.stream || !pageToRender) {
|
||||||
const stat = fs.statSync(fpath)
|
const stat = fs.statSync(fpath)
|
||||||
const fileSize = stat.size
|
const fileSize = stat.size
|
||||||
|
Reference in New Issue
Block a user