cmd_cat: Remove calls to GetReader()

This commit is contained in:
Alexander Neumann 2016-01-24 00:18:12 +01:00
parent 280d580ae2
commit 61551b0591

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
"os" "os"
"github.com/restic/restic" "github.com/restic/restic"
@ -101,20 +100,19 @@ func (cmd CmdCat) Execute(args []string) error {
return nil return nil
case "key": case "key":
rd, err := repo.Backend().GetReader(backend.Key, id.String(), 0, 0) h := backend.Handle{Type: backend.Key, Name: id.String()}
buf, err := backend.LoadAll(repo.Backend(), h, nil)
if err != nil { if err != nil {
return err return err
} }
dec := json.NewDecoder(rd) key := &repository.Key{}
err = json.Unmarshal(buf, key)
var key repository.Key
err = dec.Decode(&key)
if err != nil { if err != nil {
return err return err
} }
buf, err := json.MarshalIndent(&key, "", " ") buf, err = json.MarshalIndent(&key, "", " ")
if err != nil { if err != nil {
return err return err
} }
@ -153,12 +151,13 @@ func (cmd CmdCat) Execute(args []string) error {
switch tpe { switch tpe {
case "pack": case "pack":
rd, err := repo.Backend().GetReader(backend.Data, id.String(), 0, 0) h := backend.Handle{Type: backend.Data, Name: id.String()}
buf, err := backend.LoadAll(repo.Backend(), h, nil)
if err != nil { if err != nil {
return err return err
} }
_, err = io.Copy(os.Stdout, rd) _, err = os.Stdout.Write(buf)
return err return err
case "blob": case "blob":