From b6e6286b232d69c1849b8a12c6974c34013fa19b Mon Sep 17 00:00:00 2001 From: cyhhao Date: Sun, 5 Feb 2023 22:18:32 +0800 Subject: [PATCH] fix download bug --- src/git-remote-git3/git.ts | 1 + src/storage/SLIStorage.ts | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/git-remote-git3/git.ts b/src/git-remote-git3/git.ts index 9f7aa2a..9c31b46 100644 --- a/src/git-remote-git3/git.ts +++ b/src/git-remote-git3/git.ts @@ -42,6 +42,7 @@ class Git { for (let ref of refs) { await this.fetch(ref.oid) } + log("done.") return "\n\n" } diff --git a/src/storage/SLIStorage.ts b/src/storage/SLIStorage.ts index 08a5f15..5426270 100644 --- a/src/storage/SLIStorage.ts +++ b/src/storage/SLIStorage.ts @@ -64,8 +64,7 @@ export class SLIStorage implements Storage { Buffer.from(this.repoName), Buffer.from(path) ) - const buffer = Buffer.from(res[0].slice(2), "hex") - console.error("buffer", buffer, buffer.toString(), res[0]) + const buffer = Buffer.from(res.slice(2), "hex") const cid = buffer.toString("utf8") for (let i = 0; i < ipfsConf.gateways.length; i++) { let gateway = @@ -73,7 +72,9 @@ export class SLIStorage implements Storage { Math.floor(Math.random() * ipfsConf.gateways.length) ] //random get rpc try { - let response = await axios.get(gateway + cid) + let response = await axios.get(gateway + cid, { + responseType: "arraybuffer", + }) if (response.status === 200) { console.error(`=== download file ${path} succeed ===`) return [Status.SUCCEED, Buffer.from(response.data)]