Skip to content

Commit

Permalink
lsjson: make --stat more efficient
Browse files Browse the repository at this point in the history
Don't look for a file if the remote ends with /

This also makes it less likely to find a directory marker in bucket
based file systems.
  • Loading branch information
ncw committed Apr 28, 2023
1 parent c4a9e48 commit 335ca6d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/operations/lsjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func StatJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt)
}

// Could be a file or a directory here
if lj.files {
if lj.files && !strings.HasSuffix(remote, "/") {
// NewObject can return the sentinel errors ErrorObjectNotFound or ErrorIsDir
// ErrorObjectNotFound can mean the source is a directory or not found
obj, err := fsrc.NewObject(ctx, remote)
Expand Down

0 comments on commit 335ca6d

Please sign in to comment.