forked from TrueCloudLab/frostfs-node
[#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 <evgeniy@nspcc.ru>
This commit is contained in:
parent
923db59149
commit
a5cf38dcbf
1 changed files with 5 additions and 5 deletions
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
|
@ -193,14 +192,15 @@ func openAlphabetWallets(walletDir string) ([]*wallet.Wallet, error) {
|
||||||
|
|
||||||
var size int
|
var size int
|
||||||
loop:
|
loop:
|
||||||
for i := range walletFiles {
|
for i := 0; i < len(walletFiles); i++ {
|
||||||
for j := 0; j < len(walletFiles); j++ {
|
name := innerring.GlagoliticLetter(i).String() + ".json"
|
||||||
letter := innerring.GlagoliticLetter(j).String()
|
for j := range walletFiles {
|
||||||
if strings.HasPrefix(walletFiles[i].Name(), letter) {
|
if walletFiles[j].Name() == name {
|
||||||
size++
|
size++
|
||||||
continue loop
|
continue loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if size == 0 {
|
if size == 0 {
|
||||||
return nil, errors.New("alphabet wallets dir is empty (run `generate-alphabet` command first)")
|
return nil, errors.New("alphabet wallets dir is empty (run `generate-alphabet` command first)")
|
||||||
|
|
Loading…
Reference in a new issue