judge: remove /nix path prefix

This commit is contained in:
undefined committed 2022-08-10 01:47:31 +08:00
1 parent 6bda0e58d3
commit ad050ba1fb
3 files changed
+11 -3

No files matched your search

+9 -1
View File
@@ -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));
}
}