diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index b7e6d29ab..5a91fd8a0 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.3.3", + "version": "2.3.4", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/config.ts b/packages/hydrojudge/src/config.ts index bbc0384a1..79c836a27 100644 --- a/packages/hydrojudge/src/config.ts +++ b/packages/hydrojudge/src/config.ts @@ -55,11 +55,11 @@ if (!global.Hydro) { } const configFile = fs.readFileSync(CONFIG_FILE).toString(); config = { ...config, ...yaml.load(configFile) as any }; - if (fs.existsSync(LANGS_FILE)) config.langs = yaml.load(fs.readFileSync(LANGS_FILE).toString()); + if (fs.existsSync(LANGS_FILE)) config.langs = fs.readFileSync(LANGS_FILE).toString(); else { log.error('Language file not found, using default.'); const file = path.join(path.dirname(require.resolve('@hydrooj/hydrojudge')), 'setting.yaml'); const content = yaml.load(fs.readFileSync(file).toString()) as any; - config.langs = yaml.load(content.langs.default) as any; + config.langs = content.langs.default; } } diff --git a/packages/hydrojudge/src/hosts/hydro.ts b/packages/hydrojudge/src/hosts/hydro.ts index 608c1d4a7..a88bdbb42 100644 --- a/packages/hydrojudge/src/hosts/hydro.ts +++ b/packages/hydrojudge/src/hosts/hydro.ts @@ -30,6 +30,7 @@ class JudgeTask { code: string; tmpdir: string; clean: Function[]; + data: any[]; folder: string; config: any; nextId = 1; @@ -56,6 +57,7 @@ class JudgeTask { this.lang = this.request.lang; this.code = this.request.code; this.config = this.request.config; + this.data = this.request.data; this.tmpdir = path.resolve(getConfig('tmp_dir'), this.host, this.rid); this.clean = []; fs.ensureDirSync(this.tmpdir); @@ -79,7 +81,7 @@ class JudgeTask { }); } else { log.error(e); - this.next({ message: { message: e.message, params: e.params, ...argv.debug ? { stack: e.stack } : {} } }); + this.next({ message: { message: e.message, params: e.params || [], ...argv.debug ? { stack: e.stack } : {} } }); this.end({ status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0, }); @@ -92,7 +94,7 @@ class JudgeTask { async doSubmission() { this.stat.cache_start = new Date(); - this.folder = await this.session.cacheOpen(this.domainId, this.pid, this.next); + this.folder = await this.session.cacheOpen(this.domainId, this.pid, this.data, this.next); this.stat.read_cases = new Date(); this.config = await readCases( this.folder, @@ -192,7 +194,7 @@ export default class Hydro { const domainDir = path.join(getConfig('cache_dir'), this.config.host, domainId); const filePath = path.join(domainDir, pid); await fs.ensureDir(filePath); if (!files.length) throw new SystemError('Problem data not found.'); - let etags: Record; + let etags: Record = {}; try { etags = JSON.parse(fs.readFileSync(path.join(filePath, 'etags')).toString()); } catch (e) { /* ignore */ } @@ -210,8 +212,9 @@ export default class Hydro { operation: 'get_links', files: filenames, }); - for (const name in res.urls) { - const f = await this.axios.get(res.urls[name], { responseType: 'stream' }); + for (const name in res.data.links) { + if (name.includes('/')) await fs.ensureDir(path.join(filePath, name.split('/')[0])); + const f = await this.axios.get(res.data.links[name], { responseType: 'stream' }); const w = fs.createWriteStream(path.join(filePath, name)); f.data.pipe(w); await new Promise((resolve, reject) => { diff --git a/packages/hydrooj/src/handler/domain.ts b/packages/hydrooj/src/handler/domain.ts index 006f84fcb..3e4e81c7f 100644 --- a/packages/hydrooj/src/handler/domain.ts +++ b/packages/hydrooj/src/handler/domain.ts @@ -147,9 +147,9 @@ class DomainPermissionHandler extends ManageHandler { const perms = this.request.body[role] instanceof Array ? this.request.body[role] : [this.request.body[role]]; - // @ts-ignore + // @ts-expect-error roles[role] = 0n; - // @ts-ignore + // @ts-expect-error for (const r of perms) roles[role] |= 1n << BigInt(r); } await domain.setRoles(domainId, roles);