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

swift: fix zero length directory markekrs showing in the subdirectory listing

Nick Craig-Wood93423a0812bb
diff --git a/swift/swift.go b/swift/swift.go
index 770c81d25..5118b9aeb 100644
--- a/swift/swift.go
+++ b/swift/swift.go
@@ -297,10 +297,16 @@ func (f *Fs) listContainerRoot(container, root string, dir string, recurse bool,
if !recurse {
isDirectory = strings.HasSuffix(object.Name, "/")
}
- if !strings.HasPrefix(object.Name, root) {
+ if !strings.HasPrefix(object.Name, prefix) {
fs.Logf(f, "Odd name received %q", object.Name)
continue
}
+ if object.Name == prefix {
+ // If we have zero length directory markers ending in / then swift
+ // will return them in the listing for the directory which causes
+ // duplicate directories. Ignore them here.
+ continue
+ }
remote := object.Name[rootLength:]
err = fn(remote, object, isDirectory)
if err != nil {