This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
ipfs.add + globSource + many files will freeze #2943
Closed
Description
let ret = await addDirectoryToIPFS(ipfs, `target path`, {
options: {
pin: false,
//progress: createProgressBar,
},
globSourceOptions: {
hidden: true,
},
});
console.dir(ret.files.length);
console.dir(ret.root.cid.toString());
use v1 will can't see any thing and freeze
use v2 will see some logs, but after many runs will freeze
both can't finish job
test file
https://ipfs.io/ipfs/QmQtUGvQnYv2ZDw5GdRsaMXqjsYGp3h74BwoFHRRSFiWRZ?filename=.cache.7z
v1
export async function addDirectoryToIPFS(ipfs: IIPFSFileApi, targetDirPath: string, {
options,
globSourceOptions,
}: {
options?: IIPFSFileApiAddOptions,
globSourceOptions?: IGlobSourceOptions,
} = {})
{
let files: IIPFSFileApiAddReturnEntry[] = [];
for await (const file of ipfs.add(globSource(targetDirPath, {
recursive: true,
...globSourceOptions,
}), options))
{
console.log(file)
files.push(file);
}
const root = files[files.length - 1]
return {
targetDirPath,
root,
files,
}
}
v2
export async function addDirectoryToIPFS(ipfs: IIPFSFileApi, targetDirPath: string, {
options,
globSourceOptions,
}: {
options?: IIPFSFileApiAddOptions,
globSourceOptions?: IGlobSourceOptions,
} = {})
{
const stream = globSource(targetDirPath, {
recursive: true,
...globSourceOptions,
})
let files: IIPFSFileApiAddReturnEntry[] = [];
let root: IIPFSFileApiAddReturnEntry;
let i = 0;
// @ts-ignore
for await (const file of ipfs.add(stream, options))
{
if ((i++ % 100) === 0)
{
console.dir(file.path)
console.log(file.cid.toString());
//console.dir(root = file)
}
root = file;
}
return {
targetDirPath,
root,
files: {
length: i,
},
}
}
Metadata
Metadata
Assignees
Labels
No labels