judge: remove /nix path prefix

pull/405/head
undefined 2 years ago
parent 6bda0e58d3
commit ad050ba1fb

@ -33,7 +33,7 @@
"@types/autocannon": "^7.6.1",
"@types/cross-spawn": "^6.0.2",
"@types/mocha": "^9.1.1",
"@types/node": "^18.6.4",
"@types/node": "^18.6.5",
"@types/semver": "^7.3.10",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.29.0",

@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.22.7",
"version": "2.22.8",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",

@ -24,6 +24,10 @@ import {
const argv = cac().parse();
function removeNixPath(text: string) {
return text.replace(/\/nix\/store\/[a-z0-9]{32}-/g, '/nix/');
}
class JudgeTask {
stat: Record<string, Date>;
session: any;
@ -137,7 +141,9 @@ class JudgeTask {
log.debug('Next: %d %o', data);
data.key = 'next';
data.rid = new ObjectID(this.rid);
if (data.case) data.case.message ||= '';
if (data.case) 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));
}
@ -145,6 +151,8 @@ class JudgeTask {
log.info('End: %o', data);
data.key = 'end';
data.rid = this.request.rid;
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));
}
}

Loading…
Cancel
Save