Skip to content

Commit

Permalink
Merge pull request #3763 from nspcc-dev/index-duplicates
Browse files Browse the repository at this point in the history
cli: add warning for duplicated index files in `upload-bin`
  • Loading branch information
AnnaShaleva authored Dec 17, 2024
2 parents b86c620 + c669ae3 commit 6d20772
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions cli/util/upload_bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,16 @@ func searchIndexFile(ctx *cli.Context, p poolWrapper, containerID cid.ID, privKe
filters.AddFilter("IndexSize", fmt.Sprintf("%d", indexFileSize), object.MatchStringEqual)
for i := 0; ; i++ {
indexIDs := searchObjects(ctx.Context, p, containerID, privKeys, attributeKey, uint(i), uint(i+1), 1, maxRetries, debug, errCh, filters)
count := 0
for range indexIDs {
count++
if count > 1 {
select {
case errCh <- fmt.Errorf("duplicated index file %d found", i):
default:
}
return
}
resOIDs := make([]oid.ID, 0, 1)
for id := range indexIDs {
resOIDs = append(resOIDs, id)
}
if count == 0 {
if len(resOIDs) == 0 {
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++
}
fmt.Fprintf(ctx.App.Writer, "Current index files count: %d\n", existingIndexCount)
Expand Down

0 comments on commit 6d20772

Please sign in to comment.