From bd23ea028e526866c632a68c8a1d20a6ab26fb13 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 5 Sep 2023 17:07:44 +0100 Subject: [PATCH] azureblob: fix purging with directory markers --- backend/azureblob/azureblob.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index f2421b51a..3c5487e2b 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -1486,7 +1486,7 @@ func (f *Fs) deleteContainer(ctx context.Context, containerName string) error { func (f *Fs) Rmdir(ctx context.Context, dir string) error { container, directory := f.split(dir) // Remove directory marker file - if f.opt.DirectoryMarkers && container != "" && dir != "" { + if f.opt.DirectoryMarkers && container != "" && directory != "" { o := &Object{ fs: f, remote: dir + "/", @@ -1520,7 +1520,10 @@ func (f *Fs) Hashes() hash.Set { // Purge deletes all the files and directories including the old versions. func (f *Fs) Purge(ctx context.Context, dir string) error { container, directory := f.split(dir) - if container == "" || directory != "" { + if container == "" { + return errors.New("can't purge from root") + } + if directory != "" { // Delegate to caller if not root of a container return fs.ErrorCantPurge }