From 2395a065346152b5dd12ff181456075987f186bc Mon Sep 17 00:00:00 2001 From: KayleCoder Date: Wed, 31 Jul 2024 13:59:35 +0800 Subject: [PATCH] Adjust tonstorage util Signed-off-by: KayleCoder --- src/merkle/tonsutils.ts | 6 ++++++ src/service/storage.ts | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/merkle/tonsutils.ts b/src/merkle/tonsutils.ts index 89427da..180c77c 100644 --- a/src/merkle/tonsutils.ts +++ b/src/merkle/tonsutils.ts @@ -76,6 +76,12 @@ export async function addTonBag({ files, donwload_all, }), + }).then((res: Response) => { + if (res.status == 200) { + return res.json() + } else { + throw new Error(`Call storage api failed: ${res.status}`) + } }); } diff --git a/src/service/storage.ts b/src/service/storage.ts index b8c4372..b6e1d23 100644 --- a/src/service/storage.ts +++ b/src/service/storage.ts @@ -38,7 +38,9 @@ export async function downloadTorrentHeaders() { if (result) { continue; } - await addTonBag(torrentHash); + await addTonBag({ + bag_id: torrentHash, + }); } catch (e) { logger.error(`Failed to download meta bag ${torrentHash}: ${e.message}`); const retryTimes = task.download_header_retry_times + 1;