From 984a35f3d7a1d54cb0fabf4ca137b1b2c1d2477c Mon Sep 17 00:00:00 2001 From: cyhhao Date: Fri, 3 Mar 2023 00:02:09 +0800 Subject: [PATCH] catch sync error --- src/scripts/sync.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/scripts/sync.ts b/src/scripts/sync.ts index 4f74f9b..1f21e31 100644 --- a/src/scripts/sync.ts +++ b/src/scripts/sync.ts @@ -167,23 +167,31 @@ async function syncHub(hubAddr: string, start: number) { async function mirrorRepo(hubAddr: string, repoName: string) { let uri = `git3://${hubAddr}/${repoName}` - let res = await api.post("/repos/migrate", { - clone_addr: uri, - mirror: true, - mirror_interval: "1h", - private: false, - repo_name: repoName, - repo_owner: hubAddr, - service: "git", - uid: 0, - }) - console.log("mirrorRepo", uri, res.status) + try { + let res = await api.post("/repos/migrate", { + clone_addr: uri, + mirror: true, + mirror_interval: "1h", + private: false, + repo_name: repoName, + repo_owner: hubAddr, + service: "git", + uid: 0, + }) + console.log("mirrorRepo", uri, res.status) + } catch (e) { + console.error("mirrorRepo", e) + } } async function pullRepo(hubAddr: string, repoName: string) { let uri = `git3://${hubAddr}/${repoName}` - let res = await api.post(`/repos/${hubAddr}/${repoName}/mirror-sync`) - console.log("pullRepo", uri, res.status) + try { + let res = await api.post(`/repos/${hubAddr}/${repoName}/mirror-sync`) + console.log("pullRepo", uri, res.status) + } catch (e) { + console.error("pullRepo", e) + } } async function migrateHub(oldHubAddr: string, newHubAddr: string) {