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

azureblob: fix directory marker after // changes in #5858

Nick Craig-Wood073184132e77
diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go
index 680f1090f..2185e2cfc 100644
--- a/backend/azureblob/azureblob.go
+++ b/backend/azureblob/azureblob.go
@@ -612,6 +612,9 @@ func parsePath(path string) (root string) {
// relative to f.root
func (f *Fs) split(rootRelativePath string) (containerName, containerPath string) {
containerName, containerPath = bucket.Split(bucket.Join(f.root, rootRelativePath))
+ if f.opt.DirectoryMarkers && strings.HasSuffix(containerPath, "//") {
+ containerPath = containerPath[:len(containerPath)-1]
+ }
return f.opt.Enc.FromStandardName(containerName), f.opt.Enc.FromStandardPath(containerPath)
}
@@ -1214,7 +1217,7 @@ func (f *Fs) list(ctx context.Context, containerName, directory, prefix string,
continue
}
// process directory markers as directories
- remote = strings.TrimRight(remote, "/")
+ remote, _ = strings.CutSuffix(remote, "/")
}
remote = remote[len(prefix):]
if addContainer {
@@ -1535,7 +1538,7 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) error {
// mkdirParent creates the parent bucket/directory if it doesn't exist
func (f *Fs) mkdirParent(ctx context.Context, remote string) error {
- remote = strings.TrimRight(remote, "/")
+ remote, _ = strings.CutSuffix(remote, "/")
dir := path.Dir(remote)
if dir == "/" || dir == "." {
dir = ""
@@ -2177,11 +2180,6 @@ func (o *Object) getTags() (tags map[string]string) {
// getBlobSVC creates a blob client
func (o *Object) getBlobSVC() *blob.Client {
container, directory := o.split()
- // If we are trying to remove an all / directory marker then
- // this will have one / too many now.
- if bucket.IsAllSlashes(o.remote) {
- directory = strings.TrimSuffix(directory, "/")
- }
return o.fs.getBlobSVC(container, directory)
}
@@ -2864,6 +2862,9 @@ func (o *Object) prepareUpload(ctx context.Context, src fs.ObjectInfo, options [
return ui, err
}
}
+ // if ui.isDirMarker && strings.HasSuffix(containerPath, "//") {
+ // containerPath = containerPath[:len(containerPath)-1]
+ // }
// Update Mod time
o.updateMetadataWithModTime(src.ModTime(ctx))
diff --git a/fstest/test_all/config.yaml b/fstest/test_all/config.yaml
index 9d6baf48e..df2725d84 100644
--- a/fstest/test_all/config.yaml
+++ b/fstest/test_all/config.yaml
@@ -421,12 +421,14 @@ backends:
ignore:
# It just isn't possible to preserve the existing file with azure blob
# and make sure we don't leak uncomitted blocks.
- - TestMultithreadCopyAbort
+ - TestMultithreadCopyAbort
- backend: "azureblob"
remote: "TestAzureBlob,directory_markers:"
fastlist: true
- ignoretests:
- - cmd/bisync
+ ignore:
+ # It just isn't possible to preserve the existing file with azure blob
+ # and make sure we don't leak uncomitted blocks.
+ - TestMultithreadCopyAbort
- backend: "azurefiles"
remote: "TestAzureFiles:"
ignoretests: