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 "Entry doesn't belong in directory" errors when using directory markers

Nick Craig-Wood5f938fb9ed8a
diff --git a/backend/s3/s3.go b/backend/s3/s3.go
index 0543d89cd..6a93af10a 100644
--- a/backend/s3/s3.go
+++ b/backend/s3/s3.go
@@ -3727,11 +3727,7 @@ func (f *Fs) list(ctx context.Context, opt listOpt, fn listFn) error {
fs.Logf(f, "Odd name received %q", remote)
continue
}
- remote = remote[len(opt.prefix):]
isDirectory := (remote == "" || strings.HasSuffix(remote, "/")) && object.Size != nil && *object.Size == 0
- if opt.addBucket {
- remote = bucket.Join(opt.bucket, remote)
- }
// is this a directory marker?
if isDirectory {
if opt.noSkipMarkers {
@@ -3746,6 +3742,10 @@ func (f *Fs) list(ctx context.Context, opt listOpt, fn listFn) error {
remote = strings.TrimRight(remote, "/")
}
}
+ remote = remote[len(opt.prefix):]
+ if opt.addBucket {
+ remote = bucket.Join(opt.bucket, remote)
+ }
if versionIDs != nil {
err = fn(remote, object, versionIDs[i], isDirectory)
} else {