judge: fix warnings

This commit is contained in:
undefined committed 2022-04-03 15:11:43 +08:00
1 parent 0cb5afa169
commit 1adf04ae47
3 files changed
+2 -12

No files matched your search

@@ -1,4 +1,3 @@
import fs from 'fs-extra';
import Queue from 'p-queue';
import { STATUS } from '@hydrooj/utils/lib/status';
import compile from '../compile';
+1 -10
View File
@@ -76,17 +76,8 @@ async function postInit() {
}
async function fetchCodeFile(name: string) {
const res = await this.axios.post('judge/code', { id: name });
const f = await this.axios.get(res.body.link, { responseType: 'stream' })
.catch((e) => new Error(`DownloadFail(${name}): ${e.message}`));
if (f instanceof Error) throw f;
const target = path.join('/tmp/hydro/judge', name.replace(/\//g, '_'));
const w = fs.createWriteStream(target);
f.data.pipe(w);
await new Promise((resolve, reject) => {
w.on('finish', resolve);
w.on('error', (e) => reject(new Error(`DownloadFail(${name}): ${e.message}`)));
});
await storage.get(`submission/${name}`, target);
return target;
}
+1 -1
View File
@@ -143,7 +143,7 @@ class RecordDetailHandler extends Handler {
if (download) {
const lang = langs[rdoc.lang]?.pretest || rdoc.lang;
this.response.body = rdoc.code;
this.response.disposition = `attachment; filename="${langs[lang].code_file}` || `foo.${rdoc.lang}"`;
this.response.disposition = `attachment; filename="${langs[lang].code_file || `foo.${rdoc.lang}`}"`;
return;
}
if (pdoc && !(rdoc.contest && this.user._id === rdoc.uid)) {