init: pass proper context to master key generation
This is no change in behavior as a canceled context did later on cause the config file creation to fail. Therefore this change just lets the repository initialization fail a bit earlier.
This commit is contained in:
parent
603bb0e309
commit
a449450021
2 changed files with 3 additions and 3 deletions
|
@ -57,8 +57,8 @@ var (
|
||||||
|
|
||||||
// createMasterKey creates a new master key in the given backend and encrypts
|
// createMasterKey creates a new master key in the given backend and encrypts
|
||||||
// it with the password.
|
// it with the password.
|
||||||
func createMasterKey(s *Repository, password string) (*Key, error) {
|
func createMasterKey(ctx context.Context, s *Repository, password string) (*Key, error) {
|
||||||
return AddKey(context.TODO(), s, password, "", "", nil)
|
return AddKey(ctx, s, password, "", "", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenKey tries do decrypt the key specified by name with the given password.
|
// OpenKey tries do decrypt the key specified by name with the given password.
|
||||||
|
|
|
@ -638,7 +638,7 @@ func (r *Repository) Init(ctx context.Context, password string, chunkerPolynomia
|
||||||
// init creates a new master key with the supplied password and uses it to save
|
// init creates a new master key with the supplied password and uses it to save
|
||||||
// the config into the repo.
|
// the config into the repo.
|
||||||
func (r *Repository) init(ctx context.Context, password string, cfg restic.Config) error {
|
func (r *Repository) init(ctx context.Context, password string, cfg restic.Config) error {
|
||||||
key, err := createMasterKey(r, password)
|
key, err := createMasterKey(ctx, r, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue