From 81fccd9c39ab2c69d2e58afd5d43bba2c4861644 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 16 Jun 2025 15:07:05 +0100 Subject: [PATCH] googlecloudstorage: fix directory marker after // changes in #5858 Before this change we were creating the directory markers with double slashes on. --- backend/googlecloudstorage/googlecloudstorage.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/googlecloudstorage/googlecloudstorage.go b/backend/googlecloudstorage/googlecloudstorage.go index 7c7bec373..78a73f262 100644 --- a/backend/googlecloudstorage/googlecloudstorage.go +++ b/backend/googlecloudstorage/googlecloudstorage.go @@ -483,6 +483,9 @@ func parsePath(path string) (root string) { // relative to f.root func (f *Fs) split(rootRelativePath string) (bucketName, bucketPath string) { bucketName, bucketPath = bucket.Split(bucket.Join(f.root, rootRelativePath)) + if f.opt.DirectoryMarkers && strings.HasSuffix(bucketPath, "//") { + bucketPath = bucketPath[:len(bucketPath)-1] + } return f.opt.Enc.FromStandardName(bucketName), f.opt.Enc.FromStandardPath(bucketPath) } @@ -712,7 +715,7 @@ func (f *Fs) list(ctx context.Context, bucket, directory, prefix string, addBuck continue } // process directory markers as directories - remote = strings.TrimRight(remote, "/") + remote, _ = strings.CutSuffix(remote, "/") } remote = remote[len(prefix):] if addBucket { @@ -959,7 +962,7 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) (err error) { // mkdirParent creates the parent bucket/directory if it doesn't exist func (f *Fs) mkdirParent(ctx context.Context, remote string) error { - remote = strings.TrimRight(remote, "/") + remote, _ = strings.CutSuffix(remote, "/") dir := path.Dir(remote) if dir == "/" || dir == "." { dir = ""