diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 4ca54056a..36eea6393 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -3868,11 +3868,13 @@ func (f *Fs) list(ctx context.Context, opt listOpt, fn listFn) error { if remote == opt.directory { continue } - // process directory markers as directories - remote = strings.TrimRight(remote, "/") } } remote = remote[len(opt.prefix):] + if isDirectory { + // process directory markers as directories + remote = strings.TrimRight(remote, "/") + } if opt.addBucket { remote = bucket.Join(opt.bucket, remote) }