From b95bda1e921f3af8a4f195ece82aecddf77f0059 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 25 Aug 2023 17:39:16 +0100 Subject: [PATCH] s3: fix purging of root directory with --s3-directory-markers - fixes #7247 --- backend/s3/s3.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 18171904e..a925a8d21 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -4833,6 +4833,10 @@ func (f *Fs) purge(ctx context.Context, dir string, oldOnly bool) error { if isDirectory { return nil } + // If the root is a dirmarker it will have lost its trailing / + if remote == "" { + remote = "/" + } oi, err := f.newObjectWithInfo(ctx, remote, object, versionID) if err != nil { fs.Errorf(object, "Can't create object %+v", err)