From 72b79504ea44b0dd1b1f4112d74c5f368bccc637 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 10 Jun 2023 14:18:59 +0100 Subject: [PATCH] azureblob: fix "Entry doesn't belong in directory" errors when using directory markers Before this change we were incorrectly identifying the root directory of the listing and adding it into the listing. This caused higher layers of rclone to emit the error above. See #7038 --- backend/azureblob/azureblob.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index ec9756bb7..404b143c0 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -1063,11 +1063,7 @@ func (f *Fs) list(ctx context.Context, containerName, directory, prefix string, fs.Debugf(f, "Odd name received %q", remote) continue } - remote = remote[len(prefix):] isDirectory := isDirectoryMarker(*file.Properties.ContentLength, file.Metadata, remote) - if addContainer { - remote = path.Join(containerName, remote) - } if isDirectory { // Don't insert the root directory if remote == directory { @@ -1076,6 +1072,10 @@ func (f *Fs) list(ctx context.Context, containerName, directory, prefix string, // process directory markers as directories remote = strings.TrimRight(remote, "/") } + remote = remote[len(prefix):] + if addContainer { + remote = path.Join(containerName, remote) + } // Send object err = fn(remote, file, isDirectory) if err != nil {