-
-
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
feat(command): add force flag for files rm #5555
feat(command): add force flag for files rm #5555
Conversation
core/commands/files.go
Outdated
@@ -1002,6 +1002,7 @@ Remove files or directories. | |||
}, | |||
Options: []cmdkit.Option{ | |||
cmdkit.BoolOption("recursive", "r", "Recursively remove directories."), | |||
cmdkit.BoolOption("force", "Allow to remove anything else"), |
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.
What do you think of forcibly remove target at path; implies -r for directories
as a description?
16b8423
to
9895922
Compare
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
9895922
to
bd23e7d
Compare
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
@schomatis could u help me review this pr? But I have a question about command option: when i add |
The but that's ok, I actually prefer to just have the long explicit |
switch childi.(type) { | ||
dashr, _, _ := req.Option("r").Bool() | ||
|
||
switch child.(type) { | ||
case *mfs.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.
nit: we can now turn this single-case switch into an if
@@ -629,6 +629,20 @@ test_files_api() { | |||
test_expect_success "repo gc $EXTRA" ' | |||
ipfs repo gc | |||
' | |||
|
|||
# test rm |
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'd like to add a test with an actual corrupted node, which could just be an empty proto-node, but I'm not sure how could we add that to MFS, ipfs files cp
does check the type:
ipfs object new
# QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n
ipfs files cp /ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n /corrupted
# Error: cp: cannot flush the created file /corrupted: proto: required field "Type" not set
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.
Oh, turn off flush:
ipfs files -f=0 cp /ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n /corrupted
ipfs files rm /corrupted
# Error: proto: required field "Type" not set
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.
OT: What's the difference of adding a file in MFS without flushing? I still don't know how that works (and I'm supposedly the one in charge of reviewing the MFS API 😬)
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.
Thinking about this some more, after adding the checks to PutNode
this won't work anyways (even with flush turned off), so scratch that, I'm fine with the existing tests.
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.
LGTM
Refer to: #5538 (comment), #5554
License: MIT
Signed-off-by: Overbool overbool.xu@gmail.com