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:
parent
3a7818b403
commit
a16b950ab1
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue