Merge pull request #761 from restic/fix-758

Remove inconsistencies regarding the `cat` command
This commit is contained in:
Alexander Neumann
2017-01-30 18:25:49 +01:00
2 changed files with 9 additions and 26 deletions

View File

@@ -9,13 +9,12 @@ import (
"restic"
"restic/backend"
"restic/debug"
"restic/errors"
"restic/repository"
)
var cmdCat = &cobra.Command{
Use: "cat [flags] [pack|blob|tree|snapshot|key|masterkey|config|lock] ID",
Use: "cat [flags] [pack|blob|snapshot|key|masterkey|config|lock] ID",
Short: "print internal objects to stdout",
Long: `
The "cat" command is used to print internal objects to stdout.
@@ -172,7 +171,7 @@ func runCat(gopts GlobalOptions, args []string) error {
blob := list[0]
buf := make([]byte, blob.Length)
n, err := repo.LoadBlob(restic.DataBlob, id, buf)
n, err := repo.LoadBlob(t, id, buf)
if err != nil {
return err
}
@@ -184,23 +183,6 @@ func runCat(gopts GlobalOptions, args []string) error {
return errors.Fatal("blob not found")
case "tree":
debug.Log("cat tree %v", id.Str())
tree, err := repo.LoadTree(id)
if err != nil {
debug.Log("unable to load tree %v: %v", id.Str(), err)
return err
}
buf, err := json.MarshalIndent(&tree, "", " ")
if err != nil {
debug.Log("error json.MarshalIndent(): %v", err)
return err
}
_, err = os.Stdout.Write(append(buf, '\n'))
return nil
default:
return errors.Fatal("invalid type")
}