mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: handle run request with fileio
This commit is contained in:
1 parent
2dd9168817
commit
e23f9d2ef3
3 files changed
+5
-17
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.12.2",
|
"version": "2.12.3",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ class JudgeTask {
|
|||||||
tmpfs.mount(this.tmpdir, getConfig('tmpfs_size'));
|
tmpfs.mount(this.tmpdir, getConfig('tmpfs_size'));
|
||||||
log.info('Submission: %s/%s/%s', this.host, this.source, this.rid);
|
log.info('Submission: %s/%s/%s', this.host, this.source, this.rid);
|
||||||
try {
|
try {
|
||||||
if (typeof this.input === 'string') await this.run();
|
await this.doSubmission();
|
||||||
else await this.doSubmission();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof CompileError) {
|
if (e instanceof CompileError) {
|
||||||
this.next({ compiler_text: compilerText(e.stdout, e.stderr) });
|
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() {
|
async doSubmission() {
|
||||||
this.stat.cache_start = new Date();
|
this.stat.cache_start = new Date();
|
||||||
this.folder = await this.session.cacheOpen(this.source, this.data, this.next);
|
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')}`) },
|
{ next: this.next, key: md5(`${this.source}/${getConfig('secret')}`) },
|
||||||
);
|
);
|
||||||
this.stat.judge = new Date();
|
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]);
|
if (!judge[type]) throw new FormatError('Unrecognized problemType: {0}', [type]);
|
||||||
await judge[type].judge(this);
|
await judge[type].judge(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,8 +181,7 @@ async function postInit() {
|
|||||||
fs.ensureDirSync(this.tmpdir);
|
fs.ensureDirSync(this.tmpdir);
|
||||||
tmpfs.mount(this.tmpdir, getConfig('tmpfs_size'));
|
tmpfs.mount(this.tmpdir, getConfig('tmpfs_size'));
|
||||||
logger.info(`Submission: ${this.source}/${this.rid}`);
|
logger.info(`Submission: ${this.source}/${this.rid}`);
|
||||||
if (typeof this.input === 'string') await this.run();
|
await this.submission();
|
||||||
else await this.submission();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof CompileError) {
|
if (e instanceof CompileError) {
|
||||||
this.next({ compiler_text: compilerText(e.stdout, e.stderr) });
|
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')}`) },
|
{ next: this.next, key: md5(`${this.source}/${getConfig('secret')}`) },
|
||||||
);
|
);
|
||||||
this.stat.judge = new Date();
|
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]);
|
if (!judge[type]) throw new FormatError('Unrecognized problemType: {0}', [type]);
|
||||||
await judge[type].judge(this);
|
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));
|
task.consume({ type: 'judge' }, (t) => (new JudgeTask(t)).handle().catch(logger.error));
|
||||||
|
|||||||
Reference in new issue
Block a user