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

Before this change we were creating the directory markers with double
slashes on.
This commit is contained in:
Nick Craig-Wood 2025-06-16 15:07:05 +01:00
parent 476ff65fd7
commit 073184132e
2 changed files with 13 additions and 10 deletions

View File

@ -612,6 +612,9 @@ func parsePath(path string) (root string) {
// relative to f.root // relative to f.root
func (f *Fs) split(rootRelativePath string) (containerName, containerPath string) { func (f *Fs) split(rootRelativePath string) (containerName, containerPath string) {
containerName, containerPath = bucket.Split(bucket.Join(f.root, rootRelativePath)) 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) 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 continue
} }
// process directory markers as directories // process directory markers as directories
remote = strings.TrimRight(remote, "/") remote, _ = strings.CutSuffix(remote, "/")
} }
remote = remote[len(prefix):] remote = remote[len(prefix):]
if addContainer { 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 // mkdirParent creates the parent bucket/directory if it doesn't exist
func (f *Fs) mkdirParent(ctx context.Context, remote string) error { func (f *Fs) mkdirParent(ctx context.Context, remote string) error {
remote = strings.TrimRight(remote, "/") remote, _ = strings.CutSuffix(remote, "/")
dir := path.Dir(remote) dir := path.Dir(remote)
if dir == "/" || dir == "." { if dir == "/" || dir == "." {
dir = "" dir = ""
@ -2177,11 +2180,6 @@ func (o *Object) getTags() (tags map[string]string) {
// getBlobSVC creates a blob client // getBlobSVC creates a blob client
func (o *Object) getBlobSVC() *blob.Client { func (o *Object) getBlobSVC() *blob.Client {
container, directory := o.split() 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) return o.fs.getBlobSVC(container, directory)
} }
@ -2864,6 +2862,9 @@ func (o *Object) prepareUpload(ctx context.Context, src fs.ObjectInfo, options [
return ui, err return ui, err
} }
} }
// if ui.isDirMarker && strings.HasSuffix(containerPath, "//") {
// containerPath = containerPath[:len(containerPath)-1]
// }
// Update Mod time // Update Mod time
o.updateMetadataWithModTime(src.ModTime(ctx)) o.updateMetadataWithModTime(src.ModTime(ctx))

View File

@ -421,12 +421,14 @@ backends:
ignore: ignore:
# It just isn't possible to preserve the existing file with azure blob # It just isn't possible to preserve the existing file with azure blob
# and make sure we don't leak uncomitted blocks. # and make sure we don't leak uncomitted blocks.
- TestMultithreadCopyAbort - TestMultithreadCopyAbort
- backend: "azureblob" - backend: "azureblob"
remote: "TestAzureBlob,directory_markers:" remote: "TestAzureBlob,directory_markers:"
fastlist: true fastlist: true
ignoretests: ignore:
- cmd/bisync # 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" - backend: "azurefiles"
remote: "TestAzureFiles:" remote: "TestAzureFiles:"
ignoretests: ignoretests: