From de7223e055c3e690f01dfd7492f8afc72a2e1bb3 Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 30 Oct 2020 18:21:53 +0800 Subject: [PATCH] =?UTF-8?q?judge:=20=E9=94=99=E8=AF=AF=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++++++- packages/hydrojudge/package.json | 2 +- packages/hydrojudge/src/judge/default.ts | 4 ++-- packages/hydrojudge/src/service.ts | 20 +++++++++++++------- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/judge.ts | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 793f0c6a0..4db32d790 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,16 @@ # Hydro [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhydro-dev%2FHydro?ref=badge_shield) - Hydro是一个高效的信息学在线测评系统。特点:易于部署,轻量,功能强大且易于扩展。 +使用安装脚本(ubuntu18.04) + +```sh +curl -sSL https://cdn.jsdelivr.net/gh/hydro-dev/Hydro@master/install/ubuntu-1804.sh | bash +``` + +其他平台请参照文档手动安装。 + [中文文档](https://hydro.js.org/) 欢迎 star 本项目,这是对开发者的鼓励。 diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index 0c404d8ad..b13932008 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.1.12", + "version": "2.1.13", "main": "package.json", "author": "masnn", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/judge/default.ts b/packages/hydrojudge/src/judge/default.ts index e06487a4e..f5ed41279 100644 --- a/packages/hydrojudge/src/judge/default.ts +++ b/packages/hydrojudge/src/judge/default.ts @@ -59,7 +59,7 @@ function judgeCase(c) { checker: ctx.config.checker, checker_type: ctx.config.checker_type, score: ctxSubtask.subtask.score, - detail: ctx.config.detail, + detail: ctx.config.detail || true, }); } } else if (status === STATUS.STATUS_RUNTIME_ERROR && code) { @@ -124,7 +124,7 @@ export const judge = async (ctx) => { })(), (async () => { if (!ctx.config.checker_type || ctx.config.checker_type === 'default') { - return { execute: '', copyIn: {}, clean: Promise.resolve }; + return { execute: '', copyIn: {}, clean: () => Promise.resolve() }; } const copyIn = {}; for (const file of ctx.config.judge_extra_files) { diff --git a/packages/hydrojudge/src/service.ts b/packages/hydrojudge/src/service.ts index e3ba0f648..c34ea19fd 100644 --- a/packages/hydrojudge/src/service.ts +++ b/packages/hydrojudge/src/service.ts @@ -86,15 +86,18 @@ async function postInit() { async function cacheOpen(domainId: string, pid: string, version: string) { const filePath = path.join(homedir(), '.cache', 'hydro', 'judge', domainId, pid); - logger.debug('Cache found at %s', filePath); if (fs.existsSync(filePath)) { let ver: string; try { ver = fs.readFileSync(path.join(filePath, 'version')).toString(); } catch (e) { /* ignore */ } - if (version === ver) return filePath; - fs.removeSync(filePath); + if (version === ver) { + logger.debug('Cache found at %s', filePath); + return filePath; + } + await fs.remove(filePath); } + logger.debug('Downloading testdata to %s', filePath); fs.ensureDirSync(filePath); await problemData(domainId, pid, filePath); fs.writeFileSync(path.join(filePath, 'version'), version); @@ -108,15 +111,18 @@ async function postInit() { logger.debug('Next: %d %o', id, data); data.domainId = that.domainId; data.rid = new ObjectID(that.rid); - data.time = data.time_ms || data.time; - data.memory = data.memory_kb || data.memory; - data.compilerText = data.compiler_text || data.compilerText; + if (data.time_ms) data.time = data.time_ms; + if (data.memory_kb) data.memory = data.memory_kb; + if (data.compiler_text) data.compilerText = data.compiler_text; + delete data.time_ms; + delete data.memory_kb; + delete data.compiler_text; if (data.case) { data.case = { status: data.case.status, time: data.case.time_ms || data.case.time, memory: data.case.memory_kb || data.case.memory, - message: data.message || data.judgeText, + message: data.case.message || data.case.judgeText || '', }; } if (id) { diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index e979e5fe7..b56db0aed 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.13.29", + "version": "2.13.30", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/judge.ts b/packages/hydrooj/src/handler/judge.ts index f28b09625..73ea46091 100644 --- a/packages/hydrooj/src/handler/judge.ts +++ b/packages/hydrooj/src/handler/judge.ts @@ -42,7 +42,7 @@ export async function next(body: JudgeResultBody) { const c: TestCase = { memory: body.case.memory, time: body.case.time, - message: body.case.message, + message: body.case.message || '', status: body.case.status, }; rdoc.testCases.push(c);