Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

fix: only output unixfs things #49

Merged
merged 1 commit into from
Feb 4, 2020
Merged

Conversation

achingbrain
Copy link
Collaborator

This is a unixfs-importer but it's possible to output CIDs that resolve to dag-raw nodes if your data is small and you set rawLeaves and reduceSingleLeafToSelf to true. In that case you'll get a dag-raw node as the output.

This makes it impossible to set metadata on small files with rawLeaves set to true.

BREAKING CHANGE:

If your data is below the chunk size, and you have rawLeaves and reduceSingleLeafToSelf set to true, you'll get a CID that resolves to a bona fide UnixFS file back with metadata and all that good stuff instead of a dag-raw node.

This is a `unixfs-importer` but it's possible to output CIDs that
resolve to `dag-raw` nodes if your data is small and you set
`rawLeaves` and `reduceSingleLeafToSelf` to true. In that case
you'll get a `dag-raw` node as the output.

This makes it impossible to set metadata on small files with
`rawLeaves` set to true.

BREAKING CHANGE:

If your data is below the chunk size, and you have `rawLeaves` and
`reduceSingleLeafToSelf` set to true, you'll get a CID that resolves
to a bona fide UnixFS file back with metadata and all that good
stuff instead of a `dag-raw` node.
@achingbrain achingbrain requested a review from alanshaw January 16, 2020 10:08
achingbrain added a commit that referenced this pull request Jan 16, 2020
Builds on #49.  A separate PR as it's slightly contentious.

Sets default DAG construction to be a `dag-pb` root node, `dag-pb`
intermediate nodes and `ipld-raw` nodes for leaves.  This will make
parsing ever so slightly faster and DAG sizes ever so slightly
smaller as there is no protobuf wrapper for the actual file data.

Currently you may end up with `ipld-raw` leaves or `dag-pb` leaves
that contain UnixFS entries with type 'file' or 'raw' depending on
where the importer is invoked from.

E.g. to generate the same CIDs as go-IPFS, `ipfs.add` will result in
a balanced DAG with UnixFS leaf nodes with a type 'file',
`ipfs.files.write` will result in a trickle DAG with UnixFS leaf
nodes of a type `raw`, and specifying CID version 1 will get you
`ipld-raw` leaf nodes and whatever tree strategy you specifed,
default balanced.

I think this is chaos, we should use `ipld-raw` leaf types everywhere
and only offer options to change the DAG structure, not leaf types.
@achingbrain achingbrain merged commit 8ecdcf2 into master Feb 4, 2020
@achingbrain achingbrain deleted the output-should-be-unixfs branch February 4, 2020 11:21
@alanshaw
Copy link
Contributor

alanshaw commented Feb 4, 2020

This will break interop with go-ipfs right?

@achingbrain
Copy link
Collaborator Author

Yes, go-ipfs still outputs CIDs with the raw codec for small files with raw leaves for the time being.

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