From a44945002161de31ce3d08222c291ebcb4e13527 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 10 Apr 2020 11:37:39 +0200 Subject: [PATCH] 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. --- internal/repository/key.go | 4 ++-- internal/repository/repository.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/repository/key.go b/internal/repository/key.go index 42045389f..2c60f59e8 100644 --- a/internal/repository/key.go +++ b/internal/repository/key.go @@ -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. diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 1b4a41c31..fc58a660e 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -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 }