From bf4d0d6fdda68c3c95147fc111a86346a8d0882c Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 26 Oct 2021 15:08:05 +0800 Subject: [PATCH] core: cross-domain file id --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/problem.ts | 3 ++- packages/hydrooj/src/model/contest.ts | 4 +++- packages/migrate-vijos/script.ts | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 3112b6c59..b562b39b5 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "3.1.6", + "version": "3.1.7", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 79c098d12..6961bcd97 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -444,6 +444,7 @@ export class ProblemFilesHandler extends ProblemDetailHandler { if (type === 'testdata' && !this.user.own(this.pdoc)) { if (!this.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA)) this.checkPerm(PERM.PERM_READ_PROBLEM_DATA); } + if (this.pdoc.reference) this.pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid); const links = {}; for (const file of files) { // eslint-disable-next-line no-await-in-loop @@ -536,7 +537,7 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler { if (type === 'testdata' && !this.user.own(this.pdoc)) { if (!this.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA)) this.checkPerm(PERM.PERM_READ_PROBLEM_DATA); } - const target = `problem/${domainId}/${this.pdoc.docId}/${type}/${filename}`; + const target = `problem/${this.pdoc.domainId}/${this.pdoc.docId}/${type}/${filename}`; const file = await storage.getMeta(target); if (!file) { this.response.redirect = await storage.signDownloadLink( diff --git a/packages/hydrooj/src/model/contest.ts b/packages/hydrooj/src/model/contest.ts index 72c6bcd23..ef2532126 100644 --- a/packages/hydrooj/src/model/contest.ts +++ b/packages/hydrooj/src/model/contest.ts @@ -245,7 +245,9 @@ const oi: ContestRule = { for (const pid of tdoc.pids) { const index = `${tsdoc.uid}/${tdoc.domainId}/${pid}`; // eslint-disable-next-line @typescript-eslint/no-use-before-define - const node: ScoreboardNode = (!isExport && isDone(tdoc) && tsddict[pid]?.rid?.toHexString() !== psdict[index]?.rid?.toHexString()) + const node: ScoreboardNode = (!isExport && isDone(tdoc) + && psdict[index]?.rid + && tsddict[pid]?.rid?.toHexString() !== psdict[index]?.rid?.toHexString()) ? { type: 'records', value: '', diff --git a/packages/migrate-vijos/script.ts b/packages/migrate-vijos/script.ts index cff0e295d..a868aceb8 100644 --- a/packages/migrate-vijos/script.ts +++ b/packages/migrate-vijos/script.ts @@ -311,7 +311,6 @@ async function discussionNode(src: Db, report: Function) { function addSpace(content: string) { const lines = content.split('\r\n'); for (let i = 0; i < lines.length; i++) { - // eslint-disable-next-line no-continue if (lines[i].endsWith('|')) continue; // Markdown table; if (!lines[i].endsWith(' ')) lines[i] = `${lines[i]} `; }