core: fix reference handle

This commit is contained in:
undefined committed 2021-10-24 18:32:27 +08:00
1 parent 4aa689b508
commit 628ec7953b
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -304,7 +304,7 @@ export class ContestProblemFileDownloadHandler extends ContestProblemHandler {
async get(domainId: string, filename: string, noDisposition = false) {
if (this.pdoc.reference) {
this.pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
if (!this.pdoc) throw new ProblemNotFoundError(this.pdoc.reference.domainId, this.pdoc.reference.pid);
if (!this.pdoc) throw new ProblemNotFoundError();
}
const target = `problem/${this.pdoc.domainId}/${this.pdoc.docId}/additional_file/${filename}`;
const file = await storage.getMeta(target);
+1 -1
View File
@@ -175,7 +175,7 @@ export class HomeworkProblemFileDownloadHandler extends HomeworkDetailProblemHan
async get(domainId: string, filename: string, noDisposition = false) {
if (this.pdoc.reference) {
this.pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
if (!this.pdoc) throw new ProblemNotFoundError(this.pdoc.reference.domainId, this.pdoc.reference.pid);
if (!this.pdoc) throw new ProblemNotFoundError();
}
const target = `problem/${this.pdoc.domainId}/${this.pdoc.docId}/additional_file/${filename}`;
const file = await storage.getMeta(target);
+1 -1
View File
@@ -490,7 +490,7 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler {
if (this.pdoc.reference) {
if (type === 'testdata') throw new ForbiddenError('Cannot download testdata');
this.pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
if (!this.pdoc) throw new ProblemNotFoundError(this.pdoc.reference.domainId, this.pdoc.reference.pid);
if (!this.pdoc) throw new ProblemNotFoundError();
}
if (type === 'testdata' && !this.user.own(this.pdoc)) {
if (!this.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA)) this.checkPerm(PERM.PERM_READ_PROBLEM_DATA);