From 233ef4e8c1ab8421b8f55302b55ba1cdd4878bf8 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 10 Feb 2026 13:44:16 -0800 Subject: [PATCH] s3api: include prefix in common-prefix continuation token --- weed/s3api/s3api_object_handlers_list.go | 3 +++ weed/s3api/s3api_object_handlers_list_test.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/weed/s3api/s3api_object_handlers_list.go b/weed/s3api/s3api_object_handlers_list.go index c7971848d..2dfc9aec7 100644 --- a/weed/s3api/s3api_object_handlers_list.go +++ b/weed/s3api/s3api_object_handlers_list.go @@ -472,6 +472,9 @@ func buildTruncatedNextMarker(requestDir, prefix, nextMarker string, lastEntryWa } return requestDir + "/" + lastCommonPrefixName + "/" } + if prefix != "" { + return prefix + "/" + lastCommonPrefixName + "/" + } return lastCommonPrefixName + "/" } diff --git a/weed/s3api/s3api_object_handlers_list_test.go b/weed/s3api/s3api_object_handlers_list_test.go index 3258c2dfd..b8e1bb926 100644 --- a/weed/s3api/s3api_object_handlers_list_test.go +++ b/weed/s3api/s3api_object_handlers_list_test.go @@ -161,6 +161,11 @@ func TestBuildTruncatedNextMarker(t *testing.T) { actual := buildTruncatedNextMarker("xemu", "export_2026-02-10_17-00-23", "", true, "nested") assert.Equal(t, "xemu/export_2026-02-10_17-00-23/nested/", actual) }) + + t.Run("includes prefix for common prefix marker when request dir is empty", func(t *testing.T) { + actual := buildTruncatedNextMarker("", "foo", "", true, "bar") + assert.Equal(t, "foo/bar/", actual) + }) } func TestAllowUnorderedParameterValidation(t *testing.T) {