diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 6c15235ad..9266f7fa7 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "3.2.35", + "version": "3.2.36", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", diff --git a/packages/hydrooj/src/handler/misc.ts b/packages/hydrooj/src/handler/misc.ts index 75e089869..2344d7577 100644 --- a/packages/hydrooj/src/handler/misc.ts +++ b/packages/hydrooj/src/handler/misc.ts @@ -95,25 +95,9 @@ export class FSDownloadHandler extends Handler { target, size: file?.size || 0, }); - if (!file) { - this.response.redirect = await storage.signDownloadLink( - target, noDisposition ? undefined : filename, false, 'user', - ); - return; - } - const type = lookup(filename).toString(); - const shouldProxy = ['image', 'video', 'audio', 'pdf', 'vnd'].filter((i) => type.includes(i)).length; - if (shouldProxy && file.size! < 32 * 1024 * 1024) { - this.response.etag = file.etag; - this.response.body = await storage.get(target); - this.response.type = file['Content-Type'] || type; - if (file['Content-Encoding']) this.response.addHeader('Content-Encoding', file['Content-Encoding']); - if (!noDisposition) this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`; - } else { - this.response.redirect = await storage.signDownloadLink( - target, noDisposition ? undefined : filename, false, 'user', - ); - } + this.response.redirect = await storage.signDownloadLink( + target, noDisposition ? undefined : filename, false, 'user', + ); } } diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 29c53c342..53cfe2e9c 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -617,25 +617,9 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler { target, size: file?.size || 0, }); - if (!file) { - this.response.redirect = await storage.signDownloadLink( - target, noDisposition ? undefined : filename, false, 'user', - ); - return; - } - const fileType = lookup(filename).toString(); - const shouldProxy = ['image', 'video', 'audio', 'pdf', 'vnd'].filter((i) => fileType.includes(i)).length; - if (shouldProxy && file.size! < 32 * 1024 * 1024) { - this.response.etag = file.etag; - this.response.body = await storage.get(target); - this.response.type = file['Content-Type'] || fileType; - if (file['Content-Encoding']) this.response.addHeader('Content-Encoding', file['Content-Encoding']); - if (!noDisposition) this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`; - } else { - this.response.redirect = await storage.signDownloadLink( - target, noDisposition ? undefined : filename, false, 'user', - ); - } + this.response.redirect = await storage.signDownloadLink( + target, noDisposition ? undefined : filename, false, 'user', + ); } }