From a5cf38dcbf254e4034f6fdbea760fe02d9d4bb0d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 5 Apr 2022 10:16:35 +0300 Subject: [PATCH] [#1288] neofs-adm: Allow to store garbage in alphabet wallet dir Check the full file name instead of just prefix. Also, fix a bug where a single missing wallet could lead to an incorrect size calculation. Signed-off-by: Evgenii Stratonikov --- cmd/neofs-adm/internal/modules/morph/initialize.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index 9f6cfd97..4ef64e5b 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -5,7 +5,6 @@ import ( "fmt" "io/ioutil" "path/filepath" - "strings" "time" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" @@ -193,14 +192,15 @@ func openAlphabetWallets(walletDir string) ([]*wallet.Wallet, error) { var size int loop: - for i := range walletFiles { - for j := 0; j < len(walletFiles); j++ { - letter := innerring.GlagoliticLetter(j).String() - if strings.HasPrefix(walletFiles[i].Name(), letter) { + for i := 0; i < len(walletFiles); i++ { + name := innerring.GlagoliticLetter(i).String() + ".json" + for j := range walletFiles { + if walletFiles[j].Name() == name { size++ continue loop } } + break } if size == 0 { return nil, errors.New("alphabet wallets dir is empty (run `generate-alphabet` command first)")