pgzw
October 11, 2021, 4:53am
1
So I see that adding a file with IPFS Desktop puts it in the MFS, but I found out today that
cat test.mp4 | ipfs files write --create /test/test.mp4
and
ipfs files cp /ipfs/$(ipfs add -Q test.mp4) /test/test.mp4
can yield different hashes (according to Issue: "ipfs add" and "ipfs files write" the difference between the two? - #3 by VKingi ).
I was wondering what IPFS Desktop does, so that I can make my command line adds and my Desktop adds consistent and properly de-duplicated?
Thanks for any help!
lidel
October 11, 2021, 2:21pm
2
IPFS Desktop does ipfs add
+ ipfs files cp
because of reasons described in: Upload via WebUI (ipfs.files.write --create) produces different hash than CLI (ipfs.add) · Issue #676 · ipfs/ipfs-webui · GitHub This is a UX decision made solely to produce the same CID as command line ipfs add
. If you want the same CID in both places, use ipfs add
+ ipfs files cp
.
Digression:
files write
makes sense only when you work with append-only data, and we really should have a way for importing entire files and directories as regular dags
I think adding a dedicated files add
command would remove the confusion – filled Add 'ipfs files add' · Issue #8504 · ipfs/go-ipfs · GitHub
I think that you might be able to import entire directories with CAR files but I’m not sure about that.
lidel
October 11, 2021, 3:31pm
4
Sure, but it still requires ipfs files cp
step to create a reference in MFS after the CID is imported to the local datastore:
$ ipfs dag import dir.car
...
QmFoo
$ ipfs files cp /ipfs/QmFoo /something_in_mfs