*Make files array an object with name and size

This commit is contained in:
Derrick Hammer 2022-08-05 02:16:21 -04:00
parent 05c4fc40d9
commit d3e234c7b7
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 12 additions and 2 deletions

View File

@ -42,10 +42,15 @@ interface StatFileResponse {
contentType: string | null; contentType: string | null;
error: any; error: any;
directory: boolean; directory: boolean;
files: string[]; files: StatFileSubfile[];
timeout: boolean; timeout: boolean;
} }
interface StatFileSubfile {
name: string;
size: number;
}
async function initIpfs() { async function initIpfs() {
if (client) { if (client) {
if (client instanceof Promise) { if (client instanceof Promise) {
@ -161,7 +166,12 @@ async function statFile(hash?: string, path?: string, fullPath?: string) {
if (exists?.type === "directory") { if (exists?.type === "directory") {
stats.directory = true; 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; return stats;
} }