Repository navigation
Conversation
| if remotePath != "" { | ||
| *remote.Path = ensureTrailingPathDelimiter(remotePath) |
There was a problem hiding this comment.
remotePath = ensureTrailingPathDelimiter(remotePath)
*remote.Path = remotePathwe will need the updated remotePath for later - check if it used after this line.
There was a problem hiding this comment.
Yeah, it is used later: strings.TrimPrefix(listItem.Path, remotePath) when building relPath. The result was the same thanks to the second TrimPrefix of /, but keeping the two in sync is cleaner. Updated in the latest commit. I kept the remotePath != "" guard, since remote.Path is nil for a URI with no path and the assignment would panic there.
|
Heads up on the red "PR Requirements" check: the "Linked issue" step runs |
nopcoder
left a comment
There was a problem hiding this comment.
LGTM - left small comment related to a condition I think we can drop.
| ch := make(chan objectInfo, filesChanSize) | ||
| if remotePath != "" && !strings.HasSuffix(remotePath, uri.PathSeparator) { | ||
| *remote.Path += uri.PathSeparator | ||
| if remotePath != "" { |
There was a problem hiding this comment.
don't think this if is needed
There was a problem hiding this comment.
Yeah, not needed. The path URI parser never leaves Path nil, and the helper already returns "" as is. Removed in 602e4c3.
Closes #10582
Replaces #10600 (closed, and its fork branch is gone), with @nopcoder's review applied.
Change Description
Background
lakectl fs rm -rshould delete a folder.fs download -ralready adds a trailing/to the path, butfs rm -rdidn't.Bug Fix
lakectl fs rm -r lakefs://repo/main/logsalso deleteslogs.txtandlogs-archive/3.txt, not justlogs/1.txtandlogs/2.txt.How it happens: run the command with a path that has no trailing slash, while another object name starts with the same text.
Steps: upload
logs/1.txt,logs/2.txt,logs.txt,logs-archive/3.txt, then runlakectl fs rm -r lakefs://repo/main/logs.Expected: only
logs/1.txtandlogs/2.txtare deleted. Actual: all four are deleted.cmd/lakectl/cmd/fs_rm.gopassed the path unchanged as the list prefix, and the listing matches on a raw string prefix.ensureTrailingPathDelimiterincommon_helpers.goadds a trailing/to a non-empty path. An empty path (whole branch) is unchanged.fs rm -rnow uses it, and so do the two places that already did this by hand:fs download -randlocal init(no behavior change there).Scope:
fs ls -ris read-only and left as is, as the issue notes.Testing Details
No new unit test, per review on #10600. Ran
go build ./cmd/lakectl/...,go vet ./cmd/lakectl/cmd/,go test ./cmd/lakectl/cmd/(77 passed),gofmt -l, and golangci-lint (no findings in the touched files).Not run: esti system tests or a live lakeFS server, so the four-object steps above were not run end to end.
Environment: master @ e86d145, go1.27.1, darwin/arm64.
Breaking Change?
Behavior change:
rm -ron a path without/no longer removes siblings that share the prefix. Anyone relying on that would now need to list the sibling paths themselves.