diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index 81f0a5f94..5e09fa567 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "3.1.9", + "version": "3.1.10", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/hosts/hydro.ts b/packages/hydrojudge/src/hosts/hydro.ts index 075e1c4f7..40c639d60 100644 --- a/packages/hydrojudge/src/hosts/hydro.ts +++ b/packages/hydrojudge/src/hosts/hydro.ts @@ -145,7 +145,7 @@ export default class Hydro { send(rid: string | ObjectID, key: 'next' | 'end', data: Partial) { data.rid = new ObjectID(rid); data.key = key; - if (data.case) data.case.message = removeNixPath(data.case.message || ''); + if (data.case && typeof data.case.message === 'string') data.case.message = removeNixPath(data.case.message); if (typeof data.message === 'string') data.message = removeNixPath(data.message); if (typeof data.compilerText === 'string') data.compilerText = removeNixPath(data.compilerText); this.ws.send(JSON.stringify(data)); diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 620694ce5..ec4389e73 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -992,12 +992,10 @@ export class ProblemCreateHandler extends Handler { export class ProblemPrefixListHandler extends Handler { @param('prefix', Types.Name) async get(domainId: string, prefix: string) { - const pdocs = await problem.getPrefixList(domainId, prefix); - if (!Number.isNaN(+prefix) && !pdocs.filter((i) => i.docId === +prefix)) { - const pdoc = await problem.get(domainId, +prefix, ['domainId', 'docId', 'pid', 'title']); - if (pdoc) pdocs.unshift(pdoc); - } - const pdoc = await problem.get(domainId, prefix, ['domainId', 'docId', 'pid', 'title']); + const [pdocs, pdoc] = await Promise.all([ + problem.getPrefixList(domainId, prefix), + problem.get(domainId, Number.isSafeInteger(+prefix) ? +prefix : prefix, ['domainId', 'docId', 'pid', 'title']), + ]); if (pdoc) pdocs.unshift(pdoc); if (pdocs.length < 20) { const search = global.Hydro.lib.problemSearch || defaultSearch;