From c669ae343b7adda9daebdaff79b307c12dcc9a44 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Tue, 17 Dec 2024 13:53:19 +0300 Subject: [PATCH] cli: add warning for duplicated index files in `upload-bin` As we are not afraid of duplicates this is not a critical error anymore. BlockFetcher will take the first returned by search. Close #3762 Signed-off-by: Ekaterina Pavlova --- cli/util/upload_bin.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cli/util/upload_bin.go b/cli/util/upload_bin.go index c3fafcfc7..e5eb77de6 100644 --- a/cli/util/upload_bin.go +++ b/cli/util/upload_bin.go @@ -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)