-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix:! do not wrap with directory by default #88
Conversation
So we have at least 2 related issues here. What to about the automatic default wrap with directory, and what to do if the user explicitily requests a wrapping directory, when providing an unnamed input item... I think the range of options available to us are:
Please add if there are other options |
The option implemented in this PR is the second:
seem to be the same option here?
We need to consider this will need to be implemented at the importer level if we name it CID, which means we need to land this on Overall, I prefer the |
i think we set what if we just flip the default back to My preference has always been "dont wrap unless we detect that we need to (to avoid multiple roots)". I think the only case we need to wrap is where we get more than 1 input and they don't share a base path. |
these are almost the same, but if we require input names always, then the error is "you must provide an input name". Otherwise the error is "wrapWithDefault was set to true by default but you didnt provide an input name" |
Yes, I think we are making So, yes I am in favour of:
thoughts @alanshaw ? |
I implemented the alternative we discussed so far at #89 |
AFAIK go-ipfs requires a name with our without |
If the intention of this library is to pack/unpack CAR files compatible with IPFS then is should probably not pack a CAR with multiple roots as it's currently not possible to then use it with IPFS. My preference would be to keep the auto-wrap for avoiding multiple roots, but when it is enabled (auto or explicit), validate all the inputs have a path. |
@alanshaw can you clarify, is your prefence to always default if we're keen to enforce single root CAR files, then we should throw in the case where the user sets |
the plan, from conversation with @vasco-santos and @alanshaw
this will be a breaking change for ipfs-car so we should roll in a fix to align the sharding defaults with ipfs as per #92 |
BREAKING CHANGE: given inputs are not wrapped with a directory by default to be compliant what js-ipfs does
I confirmed that this is also a problem with current JS implementation and raised an issue to figure out a better solution across the board. Meanwhile, this should be ready to a final review so that we can get this and also #92 in as a breaking change |
@vasco-santos can you add a link to the upstream issue, just for completness. |
ipfs/js-ipfs-unixfs#176 sorry, it was just linked from there to here |
@vasco-santos i think this PR got outdated with the v1 release. Am gonna close it out. |
BREAKING CHANGE: do not wrap array inputs without path may result in different CIDs generated
On pack, unixfs importer will yield the added data + empty dir in the end. Which means that the CarWriter will receive all the blocks and the car file is well written, but the root CID will be the empty Dir.
So, what is the issue? When we pack, if we provide an ImportCandidate as new
Uint8Array([1, 2, 3])
there will be no path to create DAG Links, which means it will write both the file block and the wrapping directory block into the writer, but as it cannot infer any relationship, it will be an empty directory. However, If I provide an importCandidate as{ path: 'a.txt', content: new Uint8array([1, 2, 3] }
, then we will actually get a non empty directory.Given we provide a path (aka name) in web3.storage client, this is not a problem in web3.storage, nor in Node.js where we get the fs paths. I wonder if we should just make ipfs-car pack to not accept simple uint8array as input, despite they being perfectly valid if we do not use wrapWithDirectory . unixfs-import should probably handle this, but I don’t know if there is a reason behind the decision