From cf8c6463be69c2a2a8f0bd11c402ae7ebb03a48d Mon Sep 17 00:00:00 2001 From: Roman Tamarov Date: Fri, 21 Nov 2025 10:06:50 +0300 Subject: [PATCH] fix eachEntryFunc --- test/foundationdb/mock_integration_test.go | 11 +++++++++-- weed/filer/foundationdb/foundationdb_store.go | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/foundationdb/mock_integration_test.go b/test/foundationdb/mock_integration_test.go index fd1893eba..9639932ba 100644 --- a/test/foundationdb/mock_integration_test.go +++ b/test/foundationdb/mock_integration_test.go @@ -2,6 +2,7 @@ package foundationdb import ( "context" + "fmt" "sort" "strings" "testing" @@ -157,14 +158,20 @@ func (store *MockFoundationDBStore) ListDirectoryPrefixedEntries(ctx context.Con continue } - if !eachEntryFunc(entry) { + resEachEntryFunc, resEachEntryFuncErr := eachEntryFunc(entry) + if resEachEntryFuncErr != nil { + err = fmt.Errorf("failed to process eachEntryFunc: %w", resEachEntryFuncErr) break } + if !resEachEntryFunc { + break + } + lastFileName = entry.Name() count++ } - return lastFileName, nil + return lastFileName, err } func (store *MockFoundationDBStore) KvPut(ctx context.Context, key []byte, value []byte) error { diff --git a/weed/filer/foundationdb/foundationdb_store.go b/weed/filer/foundationdb/foundationdb_store.go index f96574107..3e18e5b23 100644 --- a/weed/filer/foundationdb/foundationdb_store.go +++ b/weed/filer/foundationdb/foundationdb_store.go @@ -474,9 +474,15 @@ func (store *FoundationDBStore) ListDirectoryPrefixedEntries(ctx context.Context continue } - if !eachEntryFunc(entry) { + resEachEntryFunc, resEachEntryFuncErr := eachEntryFunc(entry) + if resEachEntryFuncErr != nil { + glog.ErrorfCtx(ctx, "failed to process eachEntryFunc for entry %q: %v", fileName, resEachEntryFuncErr) + return lastFileName, fmt.Errorf("failed to process eachEntryFunc: %w", resEachEntryFuncErr) + } + if !resEachEntryFunc { break } + lastFileName = fileName }