2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-16 01:57:10 +00:00

repository/key: Use Load() instead of GetReader()

This commit is contained in:
Alexander Neumann 2016-01-23 23:48:19 +01:00
parent 9209dcfa26
commit 9bfa633187

View File

@ -119,17 +119,14 @@ func SearchKey(s *Repository, password string) (*Key, error) {
// LoadKey loads a key from the backend.
func LoadKey(s *Repository, name string) (k *Key, err error) {
// extract data from repo
rd, err := s.be.GetReader(backend.Key, name, 0, 0)
h := backend.Handle{Type: backend.Key, Name: name}
data, err := backend.LoadAll(s.be, h, nil)
if err != nil {
return nil, err
}
defer closeOrErr(rd, &err)
// restore json
dec := json.NewDecoder(rd)
k = new(Key)
err = dec.Decode(k)
k = &Key{}
err = json.Unmarshal(data, k)
if err != nil {
return nil, err
}