fix
This commit is contained in:
parent
b05254f163
commit
e55c7d5062
|
@ -55,16 +55,12 @@ export class DownloadService {
|
||||||
// http2: false, // default
|
// http2: false, // default
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
if (response.body === null) {
|
||||||
await pipeline(stream.Readable.fromWeb(streaming), fs.createWriteStream(path));
|
throw new StatusError('No body', 400, 'No body');
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Got.HTTPError) {
|
|
||||||
throw new StatusError(`${e.response.statusCode} ${e.response.statusMessage}`, e.response.statusCode, e.response.statusMessage);
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await pipeline(stream.Readable.fromWeb(response.body), fs.createWriteStream(path));
|
||||||
|
|
||||||
this.logger.succ(`Download finished: ${chalk.cyan(url)}`);
|
this.logger.succ(`Download finished: ${chalk.cyan(url)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue