lsjson: make --stat more efficient

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.
This commit is contained in:
Nick Craig-Wood 2023-04-27 16:38:38 +01:00
parent c4a9e480c9
commit 335ca6d572
1 changed files with 1 additions and 1 deletions

View File

@ -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)