From 4b7de2f448f45f0bb891311b12f3896bb5046508 Mon Sep 17 00:00:00 2001 From: Yang Gao <6821729+criyle@users.noreply.github.com> Date: Fri, 14 Mar 2025 18:05:23 -0400 Subject: [PATCH] judge: fix submission dispose too early & make submit_answer more efficient (#962) --- packages/hydrojudge/src/judge/submit_answer.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/hydrojudge/src/judge/submit_answer.ts b/packages/hydrojudge/src/judge/submit_answer.ts index b65357da8..949c7efff 100644 --- a/packages/hydrojudge/src/judge/submit_answer.ts +++ b/packages/hydrojudge/src/judge/submit_answer.ts @@ -15,26 +15,30 @@ function judgeCase(c: NormalizedCase) { let status = STATUS.STATUS_ACCEPTED; let message: any = ''; let score = 0; + await using cleanup = { + clean: async () => { }, + async [Symbol.asyncDispose]() { await this.clean(); }, + }; if (ctx.config.subType === 'multi') { - await using res = await runQueued( - '/usr/bin/unzip foo.zip', + const res = await runQueued( + `/usr/bin/unzip -p foo.zip ${name}`, { stdin: null, copyIn: { 'foo.zip': ctx.code }, - copyOutCached: [`${name}?`], time: 1000, memory: 128, cacheStdoutAndStderr: true, }, ); - if (res.status === STATUS.STATUS_RUNTIME_ERROR && res.code) { + cleanup.clean = async () => await res[Symbol.asyncDispose](); + if (res.status === STATUS.STATUS_RUNTIME_ERROR && res.code && res.code !== 11) { message = { message: 'Unzip failed.' }; status = STATUS.STATUS_WRONG_ANSWER; - } else if (!res.fileIds[name]) { + } else if (res.status === STATUS.STATUS_RUNTIME_ERROR && res.code && res.code === 11) { message = { message: 'File not found.' }; status = STATUS.STATUS_WRONG_ANSWER; } - file = { fileId: res.fileIds[name] }; + file = { fileId: res.fileIds['stdout'] }; } if (status === STATUS.STATUS_ACCEPTED) { ({ status, score, message } = await checkers[ctx.config.checker_type]({