Commit 762fc7f0 authored by Sietse Ringers's avatar Sietse Ringers Committed by Ivar Derksen
Browse files

refactor: when searching for a private key with a specific filename, don't use Glob

parent cf9dd009
......@@ -12,6 +12,7 @@ import (
"github.com/go-errors/errors"
"github.com/privacybydesign/gabi/big"
"github.com/privacybydesign/gabi/gabikeys"
"github.com/privacybydesign/irmago/internal/common"
)
type (
......@@ -153,15 +154,19 @@ func (p *PrivateKeyRingFolder) Latest(id IssuerIdentifier) (*gabikeys.PrivateKey
}
func (p *PrivateKeyRingFolder) Iterate(id IssuerIdentifier, f func(sk *gabikeys.PrivateKey) error) error {
files, err := filepath.Glob(filepath.Join(p.path, fmt.Sprintf("%s.xml", id.String())))
files, err := filepath.Glob(filepath.Join(p.path, fmt.Sprintf("%s.*.xml", id.String())))
if err != nil {
return err
}
filesWithCounter, err := filepath.Glob(filepath.Join(p.path, fmt.Sprintf("%s.*.xml", id.String())))
fileWithoutCounter := filepath.Join(p.path, fmt.Sprintf("%s.xml", id.String()))
exists, err := common.PathExists(fileWithoutCounter)
if err != nil {
return err
}
for _, file := range append(files, filesWithCounter...) {
if exists {
files = append(files, fileWithoutCounter)
}
for _, file := range files {
sk, err := p.readFile(filepath.Base(file), id)
if err != nil {
return err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment