mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
core: use etag when proxy files
This commit is contained in:
1 parent
ebe0a08d3e
commit
bff83350a0
5 files changed
+5
-5
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.33.2",
|
||||
"version": "2.33.3",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -325,10 +325,10 @@ export class ContestProblemFileDownloadHandler extends ContestProblemHandler {
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.response.etag = file.etag;
|
||||
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;
|
||||
this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
||||
|
||||
@@ -190,10 +190,10 @@ export class HomeworkProblemFileDownloadHandler extends HomeworkDetailProblemHan
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.response.etag = file.etag;
|
||||
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;
|
||||
this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
||||
|
||||
@@ -116,10 +116,10 @@ export class FSDownloadHandler extends Handler {
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.response.etag = file.etag;
|
||||
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;
|
||||
this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
||||
|
||||
@@ -424,10 +424,10 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler {
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.response.etag = file.etag;
|
||||
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;
|
||||
this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
||||
|
||||
Reference in new issue
Block a user