Fix 500 error which should be 404

This commit is contained in:
May 2024-03-26 16:48:28 -07:00
parent 0bf5f6f985
commit 4add8a5a8a

View file

@ -31,11 +31,12 @@ export default function(files: Files) {
ctx.header("Accept-Ranges", "bytes") ctx.header("Accept-Ranges", "bytes")
ctx.header("Access-Control-Allow-Origin", "*") ctx.header("Access-Control-Allow-Origin", "*")
ctx.header("Content-Security-Policy", "sandbox allow-scripts") ctx.header("Content-Security-Policy", "sandbox allow-scripts")
if (file) {
ctx.header("Content-Disposition", `${ctx.req.query("attachment") == "1" ? "attachment" : "inline"}; filename="${encodeURI(file.filename.replaceAll("\n","\\n"))}"`) ctx.header("Content-Disposition", `${ctx.req.query("attachment") == "1" ? "attachment" : "inline"}; filename="${encodeURI(file.filename.replaceAll("\n","\\n"))}"`)
ctx.header("ETag", file.md5) ctx.header("ETag", file.md5)
//if (file.lastModified) ctx.header("Last-Modified", new Date(file.lastModified).toTimeString()) //if (file.lastModified) ctx.header("Last-Modified", new Date(file.lastModified).toTimeString())
if (file) {
if (file.visibility == "private") { if (file.visibility == "private") {
if (acc?.id != file.owner) { if (acc?.id != file.owner) {
return ServeError(ctx, 403, "you do not own this file") return ServeError(ctx, 403, "you do not own this file")