Skip to content

Commit d680eb7

Browse files
author
Pablo Mendez
committed
use onprogress
1 parent 5be6ce0 commit d680eb7

1 file changed

Lines changed: 3 additions & 20 deletions

File tree

src/releaseUploader/ipfsNode/addFromFs.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,14 @@ export async function ipfsAddFromFs(
4343
];
4444
}
4545

46-
// Track progress
47-
let totalSize = 0;
48-
let uploadedSize = 0;
49-
for (const file of files) {
50-
const filePath = path.resolve(dirOrFilePath, file.path);
51-
if (fs.existsSync(filePath)) {
52-
const stat = fs.statSync(filePath);
53-
totalSize += stat.size;
54-
} else {
55-
// Optionally log or handle missing files
56-
continue;
57-
}
58-
}
59-
6046
// Add files to IPFS
6147
let lastCid = "";
6248
for await (const result of kuboClient.addAll(files, {
63-
wrapWithDirectory: true
49+
wrapWithDirectory: true,
50+
progress: onProgress
6451
})) {
6552
lastCid = result.cid.toString();
66-
// Progress callback (approximate)
67-
if (onProgress && result.size) {
68-
uploadedSize += result.size;
69-
onProgress(Math.min(uploadedSize / totalSize, 1));
70-
}
53+
// Progress is now handled by kuboClient.addAll's progress callback
7154
}
7255
if (!lastCid) throw Error("No CID returned from IPFS add");
7356
return `/ipfs/${lastCid}`;

0 commit comments

Comments
 (0)