From 7766fb61e833bc2e5ca3420344d0154d8abb51d7 Mon Sep 17 00:00:00 2001 From: gifi-siby Date: Thu, 16 Jan 2025 02:31:55 -0800 Subject: [PATCH] Fix for bulk insert issue in gcp native Signed-off-by: gifi-siby --- internal/storage/gcp_native_object_storage.go | 11 +++++++---- .../storage/gcp_native_object_storage_test.go | 15 ++++++--------- 2 files changed, 13 insertions(+), 13 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..3f22b9d5e8c8c 100644 --- a/internal/storage/gcp_native_object_storage_test.go +++ b/internal/storage/gcp_native_object_storage_test.go @@ -147,14 +147,11 @@ func TestGcpNativeObjectStorage(t *testing.T) { value []byte }{ {false, "abc/", []byte("123")}, - {true, "abc/d/", []byte("1234")}, - {false, "abc/d/e", []byte("12345")}, + {true, "abc/d", []byte("1234")}, {true, "abc/e/d", []byte("12354")}, {true, "key_/1/1", []byte("111")}, - {true, "key_/1/2/", []byte("222")}, - {false, "key_/1/2/3", []byte("333")}, + {true, "key_/1/2", []byte("222")}, {true, "key_/2/3", []byte("333")}, - {true, "key_/test.txt", []byte("333")}, } for _, test := range prepareTests { @@ -172,10 +169,10 @@ func TestGcpNativeObjectStorage(t *testing.T) { prefix string expectedValue []string }{ - {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"}}, + {true, "abc/", []string{"abc/d", "abc/e/d"}}, + {true, "key_/", []string{"key_/1/1", "key_/1/2", "key_/2/3"}}, + {false, "abc/", []string{"abc/d", "abc/e/"}}, + {false, "key_/", []string{"key_/1/", "key_/2/"}}, } for _, test := range insertWithPrefixTests {