mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: fix warnings
This commit is contained in:
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 Queue from 'p-queue';
|
||||||
import { STATUS } from '@hydrooj/utils/lib/status';
|
import { STATUS } from '@hydrooj/utils/lib/status';
|
||||||
import compile from '../compile';
|
import compile from '../compile';
|
||||||
|
|||||||
@@ -76,17 +76,8 @@ async function postInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchCodeFile(name: string) {
|
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 target = path.join('/tmp/hydro/judge', name.replace(/\//g, '_'));
|
||||||
const w = fs.createWriteStream(target);
|
await storage.get(`submission/${name}`, 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}`)));
|
|
||||||
});
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class RecordDetailHandler extends Handler {
|
|||||||
if (download) {
|
if (download) {
|
||||||
const lang = langs[rdoc.lang]?.pretest || rdoc.lang;
|
const lang = langs[rdoc.lang]?.pretest || rdoc.lang;
|
||||||
this.response.body = rdoc.code;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (pdoc && !(rdoc.contest && this.user._id === rdoc.uid)) {
|
if (pdoc && !(rdoc.contest && this.user._id === rdoc.uid)) {
|
||||||
|
|||||||
Reference in new issue
Block a user