mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-02 23:22:49 +00:00
Merge pull request #3763 from nspcc-dev/index-duplicates
cli: add warning for duplicated index files in `upload-bin`
This commit is contained in:
commit
6d20772714
1 changed files with 7 additions and 11 deletions
|
@ -281,20 +281,16 @@ func searchIndexFile(ctx *cli.Context, p poolWrapper, containerID cid.ID, privKe
|
||||||
filters.AddFilter("IndexSize", fmt.Sprintf("%d", indexFileSize), object.MatchStringEqual)
|
filters.AddFilter("IndexSize", fmt.Sprintf("%d", indexFileSize), object.MatchStringEqual)
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
indexIDs := searchObjects(ctx.Context, p, containerID, privKeys, attributeKey, uint(i), uint(i+1), 1, maxRetries, debug, errCh, filters)
|
indexIDs := searchObjects(ctx.Context, p, containerID, privKeys, attributeKey, uint(i), uint(i+1), 1, maxRetries, debug, errCh, filters)
|
||||||
count := 0
|
resOIDs := make([]oid.ID, 0, 1)
|
||||||
for range indexIDs {
|
for id := range indexIDs {
|
||||||
count++
|
resOIDs = append(resOIDs, id)
|
||||||
if count > 1 {
|
|
||||||
select {
|
|
||||||
case errCh <- fmt.Errorf("duplicated index file %d found", i):
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if count == 0 {
|
if len(resOIDs) == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if len(resOIDs) > 1 {
|
||||||
|
fmt.Fprintf(ctx.App.Writer, "WARN: %d duplicated index files with index %d found: %s\n", len(resOIDs), i, resOIDs)
|
||||||
|
}
|
||||||
existingIndexCount++
|
existingIndexCount++
|
||||||
}
|
}
|
||||||
fmt.Fprintf(ctx.App.Writer, "Current index files count: %d\n", existingIndexCount)
|
fmt.Fprintf(ctx.App.Writer, "Current index files count: %d\n", existingIndexCount)
|
||||||
|
|
Loading…
Reference in a new issue