diff --git a/lib/static.js b/lib/static.js index a8371cf9..dc2b53ad 100644 --- a/lib/static.js +++ b/lib/static.js @@ -65,7 +65,7 @@ class Static extends Place { const absPath = node.path.join(this.path, url); if (absPath.startsWith(this.path)) { const stat = await node.fsp.stat(absPath).catch(() => null); - if (!stat) return void transport.error(404); + if (!stat || !stat.isFile()) return void transport.error(404); const { size } = stat; const range = metarhia.metautil.parseRange(transport.req.headers.range); const { start, end = size - 1 } = range; @@ -74,9 +74,6 @@ class Static extends Place { } const options = { start, end, size }; const readable = node.fs.createReadStream(absPath, options); - readable.on('error', () => { - transport.error(404); - }); return void transport.write(readable, 206, fileExt, options); } transport.error(404);