Browse Source

fix eachEntryFunc

pull/7485/head
Roman Tamarov 2 weeks ago
parent
commit
cf8c6463be
  1. 11
      test/foundationdb/mock_integration_test.go
  2. 8
      weed/filer/foundationdb/foundationdb_store.go

11
test/foundationdb/mock_integration_test.go

@ -2,6 +2,7 @@ package foundationdb
import ( import (
"context" "context"
"fmt"
"sort" "sort"
"strings" "strings"
"testing" "testing"
@ -157,14 +158,20 @@ func (store *MockFoundationDBStore) ListDirectoryPrefixedEntries(ctx context.Con
continue continue
} }
if !eachEntryFunc(entry) {
resEachEntryFunc, resEachEntryFuncErr := eachEntryFunc(entry)
if resEachEntryFuncErr != nil {
err = fmt.Errorf("failed to process eachEntryFunc: %w", resEachEntryFuncErr)
break break
} }
if !resEachEntryFunc {
break
}
lastFileName = entry.Name() lastFileName = entry.Name()
count++ count++
} }
return lastFileName, nil
return lastFileName, err
} }
func (store *MockFoundationDBStore) KvPut(ctx context.Context, key []byte, value []byte) error { func (store *MockFoundationDBStore) KvPut(ctx context.Context, key []byte, value []byte) error {

8
weed/filer/foundationdb/foundationdb_store.go

@ -474,9 +474,15 @@ func (store *FoundationDBStore) ListDirectoryPrefixedEntries(ctx context.Context
continue 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 break
} }
lastFileName = fileName lastFileName = fileName
} }

Loading…
Cancel
Save