mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
utils: fix pipeRequest callback
This commit is contained in:
3 files changed
+6
-3
No files matched your search
@@ -327,6 +327,9 @@ export async function extractZip(zip: AdmZip, dest: string, overwrite = false, s
|
||||
export async function pipeRequest(req: superagent.Request, w: fs.WriteStream, timeout?: number, name?: string) {
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
w.on('finish', () => {
|
||||
resolve(null);
|
||||
});
|
||||
req.buffer(false).timeout({
|
||||
response: Math.min(10000, timeout),
|
||||
deadline: timeout,
|
||||
@@ -336,10 +339,10 @@ export async function pipeRequest(req: superagent.Request, w: fs.WriteStream, ti
|
||||
resp.pipe(w);
|
||||
resp.on('end', () => {
|
||||
cb(null, undefined);
|
||||
resolve(null);
|
||||
});
|
||||
resp.on('error', (err) => {
|
||||
cb(err, undefined);
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
}).catch(reject);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/utils",
|
||||
"version": "1.4.32",
|
||||
"version": "1.4.33",
|
||||
"description": "hydrooj utils",
|
||||
"main": "lib/utils.ts",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
Reference in new issue
Block a user