From 1a3b062db63558aec625b31a024e56f9319f6be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cgifi-siby=E2=80=9C?= <“gifi.s@ibm.com“> Date: Thu, 9 Jan 2025 22:09:24 -0800 Subject: [PATCH] Folders are also considered for WalkWithObjects Signed-off-by: gifi-siby --- internal/storage/gcp_native_object_storage.go | 11 +++++++---- internal/storage/gcp_native_object_storage_test.go | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/internal/storage/gcp_native_object_storage.go b/internal/storage/gcp_native_object_storage.go index a1526d33cfa5f..68e4c1a42d94b 100644 --- a/internal/storage/gcp_native_object_storage.go +++ b/internal/storage/gcp_native_object_storage.go @@ -170,10 +170,13 @@ func (gcs *GcpNativeObjectStorage) WalkWithObjects(ctx context.Context, return checkObjectStorageError(prefix, err) } if objAttrs.Prefix != "" { - continue - } - if !walkFunc(&ChunkObjectInfo{FilePath: objAttrs.Name, ModifyTime: objAttrs.Updated}) { - return nil + if !walkFunc(&ChunkObjectInfo{FilePath: objAttrs.Prefix, ModifyTime: objAttrs.Updated}) { + return nil + } + } else if objAttrs.Name != "" { + if !walkFunc(&ChunkObjectInfo{FilePath: objAttrs.Name, ModifyTime: objAttrs.Updated}) { + return nil + } } } return nil diff --git a/internal/storage/gcp_native_object_storage_test.go b/internal/storage/gcp_native_object_storage_test.go index 56e7928b2ccf6..e9a12cb4e74c1 100644 --- a/internal/storage/gcp_native_object_storage_test.go +++ b/internal/storage/gcp_native_object_storage_test.go @@ -174,8 +174,8 @@ func TestGcpNativeObjectStorage(t *testing.T) { }{ {true, "abc/", []string{"abc/e/d"}}, {true, "key_/", []string{"key_/1/1", "key_/2/3", "key_/test.txt"}}, - {false, "abc/", []string{}}, - {false, "key_/", []string{"key_/test.txt"}}, + {false, "abc/", []string{"abc/e/"}}, + {false, "key_/", []string{"key_/1/", "key_/2/", "key_/test.txt"}}, } for _, test := range insertWithPrefixTests {