From e23f9d2ef318e843f0138f97f660249e71c52bb8 Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 29 Oct 2021 17:09:20 +0800 Subject: [PATCH] judge: handle run request with fileio --- packages/hydrojudge/package.json | 2 +- packages/hydrojudge/src/hosts/hydro.ts | 10 ++-------- packages/hydrojudge/src/service.ts | 10 ++-------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index cc53c5283..5dc6d795c 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.12.2", + "version": "2.12.3", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/hosts/hydro.ts b/packages/hydrojudge/src/hosts/hydro.ts index 475009a42..3635c783a 100644 --- a/packages/hydrojudge/src/hosts/hydro.ts +++ b/packages/hydrojudge/src/hosts/hydro.ts @@ -68,8 +68,7 @@ class JudgeTask { tmpfs.mount(this.tmpdir, getConfig('tmpfs_size')); log.info('Submission: %s/%s/%s', this.host, this.source, this.rid); try { - if (typeof this.input === 'string') await this.run(); - else await this.doSubmission(); + await this.doSubmission(); } catch (e) { if (e instanceof CompileError) { this.next({ compiler_text: compilerText(e.stdout, e.stderr) }); @@ -97,11 +96,6 @@ class JudgeTask { } } - async run() { - this.stat.judge = new Date(); - await judge.run.judge(this); - } - async doSubmission() { this.stat.cache_start = new Date(); this.folder = await this.session.cacheOpen(this.source, this.data, this.next); @@ -112,7 +106,7 @@ class JudgeTask { { next: this.next, key: md5(`${this.source}/${getConfig('secret')}`) }, ); this.stat.judge = new Date(); - const type = this.config.type || 'default'; + const type = typeof this.input === 'string' ? 'run' : this.config.type || 'default'; if (!judge[type]) throw new FormatError('Unrecognized problemType: {0}', [type]); await judge[type].judge(this); } diff --git a/packages/hydrojudge/src/service.ts b/packages/hydrojudge/src/service.ts index 1e05258c7..049b2ff2f 100644 --- a/packages/hydrojudge/src/service.ts +++ b/packages/hydrojudge/src/service.ts @@ -181,8 +181,7 @@ async function postInit() { fs.ensureDirSync(this.tmpdir); tmpfs.mount(this.tmpdir, getConfig('tmpfs_size')); logger.info(`Submission: ${this.source}/${this.rid}`); - if (typeof this.input === 'string') await this.run(); - else await this.submission(); + await this.submission(); } catch (e) { if (e instanceof CompileError) { this.next({ compiler_text: compilerText(e.stdout, e.stderr) }); @@ -218,15 +217,10 @@ async function postInit() { { next: this.next, key: md5(`${this.source}/${getConfig('secret')}`) }, ); this.stat.judge = new Date(); - const type = this.config.type || 'default'; + const type = typeof this.input === 'string' ? 'run' : this.config.type || 'default'; if (!judge[type]) throw new FormatError('Unrecognized problemType: {0}', [type]); await judge[type].judge(this); } - - async run() { - this.stat.judge = new Date(); - await judge.run.judge(this); - } } task.consume({ type: 'judge' }, (t) => (new JudgeTask(t)).handle().catch(logger.error));