fix: EISDIR error in console accessing /~/plugins/NAME/
Massimo Melina committed
Apr 21, 2024 at 18:42 UTC
513ac7c5f9d304aa64c036730b37628f5d9e586a
1 file changed
+2
src/serveFile.ts
+2
@@ -72,6 +72,8 @@ export async function serveFile(ctx: Koa.Context, source:string, mime?:string, c
72
return ctx.status = HTTP_METHOD_NOT_ALLOWED
73
try {
74
const stats = await promisify(stat)(source) // using fs's function instead of fs/promises, because only the former is supported by pkg
75
+ if (!stats.isFile())
76
+ return ctx.status = HTTP_METHOD_NOT_ALLOWED
77
ctx.set('Last-Modified', stats.mtime.toUTCString())
78
ctx.fileSource = // legacy pre-0.51
79
ctx.state.fileSource = source