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 (
"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 {

8
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
}

Loading…
Cancel
Save