-
-
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
fix(cli): ipfs add with multiple files of same name #8493
Conversation
go.mod
Outdated
@@ -29,7 +29,7 @@ require ( | |||
github.com/ipfs/go-graphsync v0.8.0 | |||
github.com/ipfs/go-ipfs-blockstore v0.1.6 | |||
github.com/ipfs/go-ipfs-chunker v0.0.5 | |||
github.com/ipfs/go-ipfs-cmds v0.6.0 | |||
github.com/ipfs/go-ipfs-cmds v0.6.1-0.20211005151237-0e6ec5a05153 |
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.
Do we need to create a release here after tests pass?
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.
Once this PR is approved we should merge + release go-ipfs-cmds and bubble into this PR before merging it into master
50a62cf
to
4d916b1
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
133f0a3
to
a27afcf
Compare
What's your estimate on how long it would take to fix #8541 ? If we fix that, then all the weird edge cases here would go away, right? |
This largely depends on review bandwidth and (optionally) being able to finally consolidate UnixFS/MFS back here (as we would likely be breaking a bunch of APIs).
The general scope of that issue is too broad and vague at the moment, but achieving the specific use case of removing MFS from |
It doesn't seem like this is really about MFS as much as it is about some unintuitive behavior around what
This seems to indicate that
This seems to indicate that This behavior seems to have been introduced intentionally ages ago #1536 and while likely not that common (due to bugs like this one with multiple files with the same name not being repeated flagged + upvoted by users) it's definitely in use (e.g. a cursory look on grep.app shows https://github.com/ipfs/public-gateway-checker/blob/16c99857e4f4cb67ff5a8bc617ec9fa44bdc8a6d/publish-to-ipfs.sh#L3) In this case what happens when you do
It seems to me like the only sensible thing to do is to error if |
@aschmahmann Thanks for the detailed explanation. Could you expand a bit more on this suggestion, please?
Maybe an example of when would we error? |
The undefined behavior of when we should error is The sharness test you linked https://github.com/ipfs/go-ipfs/blob/2a871ef0184da3b021209881dfa48e3cfdaa9d26/test/sharness/t0043-add-w.sh#L131-L142 is pretty weird in that it does intentionally do the equivalent of At a high level if we want to continue to support that case (instead of just erroring from two files called foo), we can do so by either:
Aside from the fact that technically this would be an unforced breaking change, if 1 or 2 are a pain to implement we'd probably be fine to modify the sharness test and just not support entries with the same name whether they have the same path or content. We'll be generating errors so in the unlikely event this breaks someone's workflow it'll be detectable and we could deal with it later. I'd rather not have breaking changes if we can avoid it, but we can evaluate depending on how painful you think it'll be to implement. |
Got it, thanks. I think we can implement this by extending the |
According to Discord discussion we're going with:
to minimize messing around with go-ipfs-cmds or go-ipfs-files. |
I feel we have been going back and forth on the issue of which error to display to the user in My blocker is the following: AFAICT any of the proposed errors need
|
Let's roll with doing the preprocessing in go-ipfs-cmds. Does that unblock you? |
Yes, thanks. |
a27afcf
to
407eae9
Compare
@guseggert Ready for review. |
9a27cbe
to
02380b2
Compare
@guseggert Updated dependency, this should be ready now. |
This PR incorporates the
go-ipfs-cmds
fix that makes theipfs add
command not ignore repeated entries. This fix conflicts with another bug in theipfs add -w
variant of the command which can't correctly process files with the same name (I think this was uncovered here and we don't have a specific issue for it). This is shown by the shanress test failing (see more details below). We need to first fix theipfs add -w
issue before landing this so we can be confident this is the correct fix.Detail of the
ipfs add -w
bug and the test that fails (uncovering it)The
ipfs add -w (repeats)
test now fails. This is expected because:m/4r93
fileAdd()
-w
we group all the entries being added in a single directoryError: directory already has entry by that name
)We are abusing the MFS API, see related and broader issue for more details on this general topic: Decouple MFS from UnixFS.
Also note that this issue might not happen with any kind of repeated entry in the
ipfs add -w
command as empty directories seem to be ignored when constructing the path and only files within those repeated directories will trigger the error, likeipfs add -w -r dir/file dir/file
. There is some undocumented logic around path manipulation related to this:https://github.com/ipfs/go-ipfs/blob/52a747763f6c4e85b33ca051cda9cc4b75c815f9/core/coreunix/add.go#L411-L424
Fixes #8264.
cc @guseggert