From d59797229731aae52b384ee34a0a755ee170f9d8 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 6 Oct 2026 16:07:39 +0100 Subject: [PATCH] azureblob: fix listing a file as a directory on hierarchical namespace accounts Listing "dir/" on a storage account with a hierarchical namespace returns the file "dir" if it exists, so a file was listed as a directory containing itself. --- backend/azureblob/azureblob.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index 09b8c2aa5..18aba2b00 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -1318,6 +1318,13 @@ func (f *Fs) listBlobsPager(ctx context.Context, containerName, directory, prefi fs.Debugf(f, "Nil name received") continue } + // Storage accounts with a hierarchical namespace return + // the file "dir" when listing "dir/" + if !strings.HasPrefix(*file.Name, directory) { + fs.Debugf(f, "Ignoring %q not in directory %q", *file.Name, directory) + foundItems-- + continue + } remote := f.opt.Enc.ToStandardPath(*file.Name) if !strings.HasPrefix(remote, prefix) { fs.Debugf(f, "Odd name received %q", remote)