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:
Michael Eischer 2020-04-10 11:37:39 +02:00
parent 603bb0e309
commit a449450021
2 changed files with 3 additions and 3 deletions

View File

@ -57,8 +57,8 @@ var (
// createMasterKey creates a new master key in the given backend and encrypts
// it with the password.
func createMasterKey(s *Repository, password string) (*Key, error) {
return AddKey(context.TODO(), s, password, "", "", nil)
func createMasterKey(ctx context.Context, s *Repository, password string) (*Key, error) {
return AddKey(ctx, s, password, "", "", nil)
}
// OpenKey tries do decrypt the key specified by name with the given password.

View File

@ -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
// the config into the repo.
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 {
return err
}