2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-27 07:16:40 +00:00

Allow 'cat' for tree blobs

This commit is contained in:
Alexander Neumann 2016-08-28 21:23:46 +02:00
parent 6c6b0e2395
commit 3af8f53097

View File

@ -166,20 +166,24 @@ func (cmd CmdCat) Execute(args []string) error {
return err return err
case "blob": case "blob":
list, err := repo.Index().Lookup(id, pack.Data) for _, t := range []pack.BlobType{pack.Data, pack.Tree} {
if err != nil { list, err := repo.Index().Lookup(id, t)
return err if err != nil {
} continue
blob := list[0] }
blob := list[0]
buf := make([]byte, blob.Length) buf := make([]byte, blob.Length)
data, err := repo.LoadBlob(id, pack.Data, buf) data, err := repo.LoadBlob(id, t, buf)
if err != nil { if err != nil {
return err
}
_, err = os.Stdout.Write(data)
return err return err
} }
_, err = os.Stdout.Write(data) return errors.New("blob not found")
return err
case "tree": case "tree":
debug.Log("cat", "cat tree %v", id.Str()) debug.Log("cat", "cat tree %v", id.Str())