From 1dc3421c7f1ebb65ce1f6a83e842b22cb5599c7c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 16 Jun 2025 15:07:05 +0100 Subject: [PATCH] s3: fix directory marker after // changes in #5858 Before this change we were creating the directory markers with double slashes on. --- backend/s3/s3.go | 7 +++++-- fstest/test_all/config.yaml | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 3171f6ad1..2b4c7d62d 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -3136,6 +3136,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) } @@ -4458,7 +4461,7 @@ func (f *Fs) list(ctx context.Context, opt listOpt, fn listFn) error { remote = remote[len(opt.prefix):] if isDirectory { // process directory markers as directories - remote = strings.TrimRight(remote, "/") + remote, _ = strings.CutSuffix(remote, "/") } if opt.addBucket { remote = bucket.Join(opt.bucket, remote) @@ -4773,7 +4776,7 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) 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 = "" diff --git a/fstest/test_all/config.yaml b/fstest/test_all/config.yaml index df2725d84..1c1fc3262 100644 --- a/fstest/test_all/config.yaml +++ b/fstest/test_all/config.yaml @@ -230,8 +230,6 @@ backends: - backend: "s3" remote: "TestS3,directory_markers:" fastlist: true - ignoretests: - - cmd/bisync - backend: "s3" remote: "TestS3Rclone:" fastlist: true