fix handling of maxKeys in SearchKey
This commit is contained in:
parent
1dd4b9b60e
commit
f144920ed5
2 changed files with 11 additions and 0 deletions
10
changelog/unreleased/pull-3776
Normal file
10
changelog/unreleased/pull-3776
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Bugfix: Limit number of key files tested while opening a repository
|
||||||
|
|
||||||
|
Previously, restic tested the password against every key in the repository, when
|
||||||
|
there are more and more keys in the repository, opening the repository becomes
|
||||||
|
slower and slower.
|
||||||
|
|
||||||
|
Now restic tests password up to 20 times on the key file in the repository, or
|
||||||
|
you can use `-key-hint=<Key ID>` to specify the key file to be used.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/pull/3776
|
|
@ -137,6 +137,7 @@ func SearchKey(ctx context.Context, s *Repository, password string, maxKeys int,
|
||||||
|
|
||||||
// try at most maxKeys keys in repo
|
// try at most maxKeys keys in repo
|
||||||
err = s.Backend().List(listCtx, restic.KeyFile, func(fi restic.FileInfo) error {
|
err = s.Backend().List(listCtx, restic.KeyFile, func(fi restic.FileInfo) error {
|
||||||
|
checked++
|
||||||
if maxKeys > 0 && checked > maxKeys {
|
if maxKeys > 0 && checked > maxKeys {
|
||||||
return ErrMaxKeysReached
|
return ErrMaxKeysReached
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue