-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coreapi unixfs: change Wrap logic to make more sense #6019
Conversation
As far as I know, I can see how it is a bit weird that it doesn't happen in case of directories but I have to highlight that it is quite a big breaking change and I would expect would break existing workflows and scripts. |
|
0f22695
to
b80801f
Compare
c5b6009
to
9e2b237
Compare
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2b0ea9f
to
152829d
Compare
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
36afdea
to
cfa4862
Compare
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
3b75b06
to
01ef512
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having trouble understanding this.
- What's this "top level" thing and can we get rid of it? It seems like we're mixing two code paths with some shared logic.
- Why do I care if a file is a directory or not when adding it?
|
||
// if adding a file without wrapping, swap the root to it (when adding a | ||
// directory, mfs root is the directory) | ||
_, dir := file.(files.Directory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having trouble understanding this comment. Why do we care if the file we're adding is a directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It made sense before I rewrote this code.
Here's my attempt to simplify this: #6121. It may be totally wrong but it'll at least help me better understand how this all works. |
When adding a directory, we add its entries to mfs (so mfs root is the directory). When adding a file, we also add it to mfs with its hash as the name so that wrap works. If we could drop wrap from adder/coreapi it would make this much simpler (we wouldn't use mfs at all when adding single files) |
Unless you can think of a reason not to, let's just do that. It's really trivial to wrap a file anyways. |
go.mod
Outdated
@@ -33,12 +33,12 @@ require ( | |||
github.com/ipfs/go-ipfs-blocksutil v0.0.1 | |||
github.com/ipfs/go-ipfs-chunker v0.0.1 | |||
github.com/ipfs/go-ipfs-cmdkit v0.0.1 | |||
github.com/ipfs/go-ipfs-cmds v0.0.2 | |||
github.com/ipfs/go-ipfs-cmds v0.0.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs v0.0.4
to cover #6118
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
becec73
to
2d96b4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ok, I'm not going to block this on my now massive PR)
coreapi unixfs: change Wrap logic to make more sense This commit was moved from ipfs/kubo@8c96e3b
Currently
coreunix.Adder
wrap logic is weird, which causescoreapi.Unixfs().Add
to also be weird:With this PR it does this:
New behaviour IMO makes much more sense from API consumer perspective.
TODO:
Reviews welcome