From 335ca6d5726ac4d1723dc9770a2e615bafbc84ac Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 27 Apr 2023 16:38:38 +0100 Subject: [PATCH] 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. --- fs/operations/lsjson.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/operations/lsjson.go b/fs/operations/lsjson.go index 176c2cb9f..6c94ee6ee 100644 --- a/fs/operations/lsjson.go +++ b/fs/operations/lsjson.go @@ -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)