Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

fix: build & export interop with go-ipfs for small file raw leaves #228

Merged
merged 2 commits into from
Aug 23, 2018

Conversation

alanshaw
Copy link
Contributor

@alanshaw alanshaw commented Aug 23, 2018

For files smaller than max chunk size and raw leaves true, go-ipfs will create a single node that is a raw buffer. Prior to this PR, js-ipfs created a unixfs file node who's data was the raw buffer. This resulted in different hashes for the same file.

This PR changes the builder to do the same thing as go-ipfs and adds a resolver to the exporter that allows the exporter to export a node that is a single raw buffer (so that you can ipfs cat [CID w codec raw] as you can in go-ipfs).

I was going to write an interop test but it's already here and this PR should aid that branch to pass.

refs ipfs/js-ipfs#1523

For files smaller than max chunk size and raw leaves true, go-ipfs will create a single node that is a raw buffer. Prior to this PR, js-ipfs created a unixfs file node who's data was the raw buffer. This resulted in different hashes for the same file.

This PR changes the builder to do the same thing as go-ipfs and adds a resolver to the exporter that allows the exporter to export a node that is a single raw buffer (so that you can `ipfs cat [CID w codec raw]` as you can in go-ipfs).

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
@ghost ghost assigned alanshaw Aug 23, 2018
@ghost ghost added the status/in-progress In progress label Aug 23, 2018
@achingbrain achingbrain self-requested a review August 23, 2018 11:50
Copy link
Collaborator

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code coverage has decreased slightly with this PR - I think it's because of the copy/pasted validation for offset/length/etc in the new raw node exporter. Maybe pull this into a separate function shared with the file exporter to reduce the duplication?

Also fixes an issue with the file resolver and 0 length export.

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
@alanshaw
Copy link
Contributor Author

👍 now? :D

@achingbrain achingbrain merged commit 2a70780 into ipfs-inactive:master Aug 23, 2018
@achingbrain achingbrain deleted the fix/raw-leaves branch August 23, 2018 16:19
@ghost ghost removed the status/in-progress In progress label Aug 23, 2018
@achingbrain
Copy link
Collaborator

Released in v0.32.4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants