judge: also catch get error

This commit is contained in:
undefined committed 2021-10-29 18:01:07 +08:00
1 parent 6ebadeeb6d
commit 5c3b13be82
2 files changed
+4 -2

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.12.4",
"version": "2.12.5",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
+3 -1
View File
@@ -207,7 +207,9 @@ export default class Hydro {
// eslint-disable-next-line no-inner-declarations
async function download(name: string) {
if (name.includes('/')) await fs.ensureDir(path.join(filePath, name.split('/')[0]));
const f = await this.axios.get(res.data.links[name], { responseType: 'stream' });
const f = await this.axios.get(res.data.links[name], { responseType: 'stream' })
.catch((e) => new Error(`DownloadFail(${name}): ${e.message}`));
if (f instanceof Error) throw f;
const w = fs.createWriteStream(path.join(filePath, name));
f.data.pipe(w);
await new Promise((resolve, reject) => {