Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

s3: fix slice bounds out of range error when listing

Nick Craig-Woodb296f3780137
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)
}