From d3e234c7b7335107aac8b6942c98a77bbe53787b Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 5 Aug 2022 02:16:21 -0400 Subject: [PATCH] *Make files array an object with name and size --- src/rpc/ipfs.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rpc/ipfs.ts b/src/rpc/ipfs.ts index 1d7d83d..f639bd4 100644 --- a/src/rpc/ipfs.ts +++ b/src/rpc/ipfs.ts @@ -42,10 +42,15 @@ interface StatFileResponse { contentType: string | null; error: any; directory: boolean; - files: string[]; + files: StatFileSubfile[]; timeout: boolean; } +interface StatFileSubfile { + name: string; + size: number; +} + async function initIpfs() { if (client) { if (client instanceof Promise) { @@ -161,7 +166,12 @@ async function statFile(hash?: string, path?: string, fullPath?: string) { if (exists?.type === "directory") { stats.directory = true; - stats.files = exists.node.Links.map((item) => item.Name) as string[]; + stats.files = exists.node.Links.map((item) => { + return { + name: item.Name, + size: item.Tsize, + } as StatFileSubfile; + }); return stats; }