Ipfs add with glob source

I am using ipfs-http-client's latest version…

// @ts-ignore
  const ipfs = create(ipfsApiUrl)

  // @ts-ignore
  const root = await ipfs.add(globSource(dirPath, { recursive: true, ignore }))

The result is one hash, not multipl even though my dirPath contains multiple files.

How does this work ? if it gives me only one root, does it mean that single files in dirPath are not added to ipfs separately ? If so, it’s kind of bad, because i am planning to do pinning and if that’s so, it’s possible that my root hash will be pinned, but single files inside it might get removed because I’ve not pinned them and how would I pin them at all if I don’t have separate hashes for each one of them ?

I’d appreciate your input on this.

When you add a directory it will give you the root CID. That CID points to all the files inside.

Try exploring the CID.



Thanks for the follow up.

So it’s not possible that If I only pin the root hash, one of the files inside it might disappear ? right ? in another way, pinning the root has means I pin all the files inside it ? correct ?

Yes, by default it’s a recursive pin. It pins everything linked to the root CID.

Direct pin is when you don’t want what’s linked to be pinned.