From 073184132e77837d383db49492080d744252fd8b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 16 Jun 2025 15:07:05 +0100 Subject: [PATCH] azureblob: fix directory marker after // changes in #5858 Before this change we were creating the directory markers with double slashes on. --- backend/azureblob/azureblob.go | 15 ++++++++------- fstest/test_all/config.yaml | 8 +++++--- 2 files changed, 13 insertions(+), 10 deletions(-) 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: