judge: subtask parser fix

This commit is contained in:
undefined committed 2021-11-27 23:23:27 +08:00
1 parent 1704d7261d
commit b4b700890c
2 files changed
+7 -6

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.12.7", "version": "2.12.8",
"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",
+6 -5
View File
@@ -113,20 +113,21 @@ async function read1(folder: string, files: string[], checkFile, cfg, rst) {
for (const REG of RE1) { for (const REG of RE1) {
if (REG.reg.test(file)) { if (REG.reg.test(file)) {
const data = REG.reg.exec(file); const data = REG.reg.exec(file);
const sid = REG.subtask(data);
const c = { input: file, output: '', id: REG.id(data) }; const c = { input: file, output: '', id: REG.id(data) };
for (const func of REG.output) { for (const func of REG.output) {
if (cfg.noOutputFile) c.output = '/dev/null'; if (cfg.noOutputFile) c.output = '/dev/null';
else c.output = func(data); else c.output = func(data);
if (c.output === '/dev/null' || fs.existsSync(path.resolve(folder, c.output))) { if (c.output === '/dev/null' || fs.existsSync(path.resolve(folder, c.output))) {
if (!subtask[REG.subtask(data)]) { if (!subtask[sid]) {
subtask[REG.subtask(data)] = [{ subtask[sid] = {
time: parseTimeMS(cfg.time || '1s'), time: parseTimeMS(cfg.time || '1s'),
memory: parseMemoryMB(cfg.memory || '256m'), memory: parseMemoryMB(cfg.memory || '256m'),
type: 'min', type: 'min',
cases: [c], cases: [c],
}]; };
} else if (!subtask[REG.subtask(data)].cases) subtask[REG.subtask(data)].cases = [c]; } else if (!subtask[sid].cases) subtask[sid].cases = [c];
else subtask[REG.subtask(data)].cases.push(c); else subtask[sid].cases.push(c);
break; break;
} }
} }