-
-
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(cmds/add): disallow --wrap with --to-files #10612
Conversation
Fixes #10611. When we are adding to an MFS folder ("--to-files=folder/"), we append the filename to the folder name. However, when wrapping, the wrapping folder has no name and `path.Base("")` returns `.`. This creates a folder named "." inside the previous one. But mfs operations like `ls` think that "." is the current folder, and does not contemplate the option of a folder of name ".". Dealing with unnamed files in MFS is in general a footgun, so this commits attempts to prohibit that case.
9378dbb
to
b320438
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.
Thank you, sensible fix, added test to guard this.
@@ -32,6 +39,4 @@ If you depended on removed ones, please fill an issue to add them to the upstrea | |||
|
|||
### 📝 Changelog | |||
|
|||
- Fix: unnamed files in MFS. Disallow `--wrap` + `--to-files` when adding ([#10611](https://github.com/ipfs/kubo/issues/10611), [#10612](https://github.com/ipfs/kubo/issues/10612)) |
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.
ℹ️ @hsanjuan fysa the Changelo section is generated during Kubo release (we have cli tool that pulls commits/prs from kubo/boxo/go-libp2p etc), moved this to "Highlights" section.
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.
Thanks!! Won't forget next time.
# confirm -w and --to-files are exclusive | ||
# context: https://github.com/ipfs/kubo/issues/10611 | ||
test_expect_success "ipfs add -r -w dir --to-files /mfs/subdir5/ errors (-w and --to-files are exclusive)" ' | ||
ipfs files mkdir -p /mfs/subdir5 && | ||
test_expect_code 1 ipfs add -r -w test --to-files /mfs/subdir5/ >actual 2>&1 && | ||
test_should_contain "Error" actual && | ||
ipfs files rm -r --force /mfs | ||
' | ||
|
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.
ℹ️ added basic regression test that guards this behavior
Fixes #10611.
When we are adding to an MFS folder ("--to-files=folder/"), we append the filename to the folder name.
However, when wrapping, the wrapping folder has no name and
path.Base("")
returns.
.This creates a folder named "." inside the previous one. But mfs operations like
ls
think that "." is the current folder, and does not contemplate the option of a folder of name ".".Dealing with unnamed files in MFS is in general a footgun, so this commits attempts to prohibit that case.