diff --git a/packages/hydrojudge/src/service.ts b/packages/hydrojudge/src/service.ts index 8a870f366..970554cf5 100644 --- a/packages/hydrojudge/src/service.ts +++ b/packages/hydrojudge/src/service.ts @@ -71,6 +71,7 @@ async function postInit() { } async function cacheOpen(domainId: string, pid: string, files: any[]) { + console.log(files); const filePath = path.join(getConfig('cache_dir'), domainId, pid); await fs.ensureDir(filePath); if (!files.length) throw new SystemError('Problem data not found.'); @@ -82,7 +83,7 @@ async function postInit() { for (const file of files) { version[file.name] = file.etag; if (etags[file.name] !== file.etag) { - await storage.get(`${file.prefix}${file.name}`, path.join(filePath, file.name)); + await storage.get(`problem/${domainId}/${pid}/testdata/${file.name}`, path.join(filePath, file.name)); } } fs.writeFileSync(path.join(filePath, 'etags'), JSON.stringify(version)); diff --git a/packages/hydrooj/locales/zh.yaml b/packages/hydrooj/locales/zh.yaml index 174c91a4a..23183fde2 100644 --- a/packages/hydrooj/locales/zh.yaml +++ b/packages/hydrooj/locales/zh.yaml @@ -538,6 +538,7 @@ problem_create: 创建题目 problem_detail: 题目详情 problem_edit: 编辑题目 problem_files: 题目文件 +problem_import_syzoj: 从 SYZOJ 导入题目 problem_import: 导入题目 problem_main: 题库 problem_settings: 题目设置 diff --git a/packages/hydrooj/src/entry/cli.ts b/packages/hydrooj/src/entry/cli.ts index 85b26eba8..f50efdddc 100644 --- a/packages/hydrooj/src/entry/cli.ts +++ b/packages/hydrooj/src/entry/cli.ts @@ -8,7 +8,6 @@ import { import options from '../options'; import * as bus from '../service/bus'; import db from '../service/db'; -import storage from '../service/storage'; const COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; const ARR = /=>.*$/mg; @@ -26,6 +25,9 @@ async function cli() { if (!global.Hydro.model[modelName]) { return console.error(`Model ${modelName} doesn't exist.`); } + if (!func) { + return console.log(Object.keys(global.Hydro.model[modelName])); + } if (!global.Hydro.model[modelName][func]) { return console.error(`Function ${func} doesn't exist in model ${modelName}.`); } @@ -65,6 +67,7 @@ export async function load() { const sopts = { endPoint, accessKey, secretKey, bucket, region, endPointForUser, endPointForJudge, }; + const storage = require('../service/storage'); await storage.start(sopts); for (const i of builtinLib) require(`../lib/${i}`); await lib(pending, fail); diff --git a/packages/hydrooj/src/handler/homework.ts b/packages/hydrooj/src/handler/homework.ts index 59afc6b94..02d2f8151 100644 --- a/packages/hydrooj/src/handler/homework.ts +++ b/packages/hydrooj/src/handler/homework.ts @@ -370,7 +370,7 @@ class HomeworkScoreboardDownloadHandler extends HomeworkHandler { html: (rows) => this.renderHTML('contest_scoreboard_download_html.html', { rows }), }; if (!getContent[ext]) throw new ValidationError('ext'); - const [, rows] = await this.getScoreboard(domainId, tid, true, document.TYPE_CONTEST); + const [, rows] = await this.getScoreboard(domainId, tid, true, document.TYPE_HOMEWORK); this.binary(await getContent[ext](rows), `${this.tdoc.title}.${ext}`); } } diff --git a/packages/hydrooj/src/handler/import.syzoj.ts b/packages/hydrooj/src/handler/import.syzoj.ts index bba3c1815..c1888b324 100644 --- a/packages/hydrooj/src/handler/import.syzoj.ts +++ b/packages/hydrooj/src/handler/import.syzoj.ts @@ -247,12 +247,12 @@ class ProblemImportSYZOJHandler extends Handler { domainId, targetPid, hidden, protocol, host, pid, false, ); - this.response.body = { pid: pid || docId }; - this.response.redirect = this.url('problem_settings', { pid: pid || docId }); + this.response.body = { pid: targetPid || docId }; + this.response.redirect = this.url('problem_settings', { pid: targetPid || docId }); } else { const docId = await this.v2(domainId, targetPid, hidden, url); - this.response.body = { pid: pid || docId }; - this.response.redirect = this.url('problem_settings', { pid: pid || docId }); + this.response.body = { pid: targetPid || docId }; + this.response.redirect = this.url('problem_settings', { pid: targetPid || docId }); } } } diff --git a/packages/hydrooj/src/interface.ts b/packages/hydrooj/src/interface.ts index 1ec85365b..a8427eca4 100644 --- a/packages/hydrooj/src/interface.ts +++ b/packages/hydrooj/src/interface.ts @@ -185,9 +185,7 @@ declare module './model/problem' { difficultyAdmin?: number, difficultySetting?: any, - /** - * @deprecated - */ + /** @deprecated */ config: any, } } diff --git a/packages/hydrooj/src/model/builtin.ts b/packages/hydrooj/src/model/builtin.ts index f1c126415..408d400af 100644 --- a/packages/hydrooj/src/model/builtin.ts +++ b/packages/hydrooj/src/model/builtin.ts @@ -18,9 +18,7 @@ export const PERM = { // Problem and Record PERM_CREATE_PROBLEM: 1n << 4n, PERM_EDIT_PROBLEM: 1n << 5n, - /** - * @deprecated - */ + /** @deprecated */ PERM_EDIT_PROBLEM_SELF: 1n << 6n, PERM_VIEW_PROBLEM: 1n << 7n, PERM_VIEW_PROBLEM_HIDDEN: 1n << 8n, @@ -237,21 +235,13 @@ export const PRIV = { PRIV_DEFAULT: 0, PRIV_NEVER: 1 << 20, - /** - * @deprecated - */ + /** @deprecated */ PRIV_CREATE_FILE: 1 << 16, - /** - * @deprecated - */ + /** @deprecated */ PRIV_UNLIMITED_QUOTA: 1 << 17, - /** - * @deprecated - */ + /** @deprecated */ PRIV_DELETE_FILE: 1 << 18, - /** - * @deprecated - */ + /** @deprecated */ PRIV_DELETE_FILE_SELF: 1 << 19, }; diff --git a/packages/hydrooj/src/service/server.ts b/packages/hydrooj/src/service/server.ts index f5564f036..ae36efa6a 100644 --- a/packages/hydrooj/src/service/server.ts +++ b/packages/hydrooj/src/service/server.ts @@ -304,7 +304,7 @@ export class HandlerCommon { try { const { anchor } = args; if (args.domainId) name += '_with_domainId'; - else if (this.domain.host !== this.request.host && this.domainId !== 'system') { + else if (this.domain?.host !== this.request.host && this.domainId !== 'system') { name += '_with_domainId'; args.domainId = this.domainId; }