judge: handle run request with fileio

This commit is contained in:
undefined committed 2021-10-29 17:09:20 +08:00
1 parent 2dd9168817
commit e23f9d2ef3
3 files changed
+5 -17

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.12.2",
"version": "2.12.3",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
+2 -8
View File
@@ -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);
}
+2 -8
View File
@@ -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));