ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
15.83k stars 2.96k forks source link

Add basic UnixFS sanity check to 'ipfs files cp' #10331

Open lidel opened 3 months ago

lidel commented 3 months ago

https://github.com/ipfs/kubo/issues/7999, https://github.com/ipfs/kubo/issues/8144, https://github.com/ipfs/kubo/issues/7172 still hunts us https://github.com/ipfs/ipfs-webui/issues/2205.

I think we should make ipfs files cp /ipfs/cid /mfs-destination at least check the root cid, and error if it is not a valid UnixFS node or has codec other than raw or dag-pb.

This way it is less likely people import non-UnixFS to MFS (majority of time, it will be root cid at fault). This would fix both CLI and ipfs-webui.

ps. while we are at this, we should also add --force mentioned in https://github.com/ipfs/kubo/issues/2074 (we already have it for rm, but not cp)

SgtPooki commented 3 months ago

When people attempt to add content that is not unixfs to MFS, should we prompt users to re-encode the data as unix-fs? I feel like the majority of webui users are unaware what type of content CIDs they're passing around is, and likely just want to add it to webui/desktop. The easier we make that, the happier they would be.