diff --git a/cmd/restic/main.go b/cmd/restic/main.go index a6de28edf..d5d7cd169 100644 --- a/cmd/restic/main.go +++ b/cmd/restic/main.go @@ -74,7 +74,7 @@ func (cmd CmdInit) Execute(args []string) error { } s := server.NewServer(be) - err = s.CreateMasterKey(pw) + err = s.Init(pw) if err != nil { fmt.Fprintf(os.Stderr, "creating key in backend at %s failed: %v\n", opts.Repo, err) os.Exit(1) diff --git a/server/server.go b/server/server.go index e896c7dec..c6fc9732c 100644 --- a/server/server.go +++ b/server/server.go @@ -532,7 +532,7 @@ func (s *Server) loadIndex(id string) error { const repositoryIDSize = sha256.Size const RepositoryVersion = 1 -func (s *Server) createConfig() (err error) { +func createConfig(s *Server) (err error) { s.Config.ChunkerPolynomial, err = chunker.RandomPolynomial() if err != nil { return err @@ -583,9 +583,9 @@ func (s *Server) SearchKey(password string) error { return s.loadConfig(&s.Config) } -// CreateMasterKey creates a new key with the supplied password, afterwards the -// repository config is created. -func (s *Server) CreateMasterKey(password string) error { +// Init creates a new master key with the supplied password and initializes the +// repository config. +func (s *Server) Init(password string) error { has, err := s.Test(backend.Config, "") if err != nil { return err @@ -601,7 +601,7 @@ func (s *Server) CreateMasterKey(password string) error { s.key = key.master s.keyName = key.Name() - return s.createConfig() + return createConfig(s) } func (s *Server) Decrypt(ciphertext []byte) ([]byte, error) { diff --git a/server/server_test.go b/server/server_test.go index 83a41bb08..0f44def1c 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -172,7 +172,7 @@ func TestLoadJSONPack(t *testing.T) { OK(t, err) } -func TestLoadJSONEncrypted(t *testing.T) { +func TestLoadJSONUnpacked(t *testing.T) { if *benchTestDir == "" { t.Skip("benchdir not set, skipping TestServerStats") } diff --git a/test/backend.go b/test/backend.go index c7db75135..5a2524425 100644 --- a/test/backend.go +++ b/test/backend.go @@ -30,7 +30,7 @@ func SetupBackend(t testing.TB) *server.Server { OK(t, err) s := server.NewServer(b) - OK(t, s.CreateMasterKey(*TestPassword)) + OK(t, s.Init(*TestPassword)) return s }