Merge pull request #3895 from MichaelEischer/refactor-cat-key

cat: Simplify implementation of 'cat key'
This commit is contained in:
Alexander Neumann 2022-08-27 18:40:46 +02:00 committed by GitHub
commit c169e37139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -100,19 +100,12 @@ func runCat(gopts GlobalOptions, args []string) error {
Println(string(buf))
return nil
case "key":
h := restic.Handle{Type: restic.KeyFile, Name: id.String()}
buf, err := backend.LoadAll(gopts.ctx, nil, repo.Backend(), h)
key, err := repository.LoadKey(gopts.ctx, repo, id.String())
if err != nil {
return err
}
key := &repository.Key{}
err = json.Unmarshal(buf, key)
if err != nil {
return err
}
buf, err = json.MarshalIndent(&key, "", " ")
buf, err := json.MarshalIndent(&key, "", " ")
if err != nil {
return err
}