mirror of
https://github.com/octoleo/restic.git
synced 2024-11-23 13:17:42 +00:00
Allow 'cat' for tree blobs
This commit is contained in:
parent
6c6b0e2395
commit
3af8f53097
@ -166,20 +166,24 @@ func (cmd CmdCat) Execute(args []string) error {
|
||||
return err
|
||||
|
||||
case "blob":
|
||||
list, err := repo.Index().Lookup(id, pack.Data)
|
||||
for _, t := range []pack.BlobType{pack.Data, pack.Tree} {
|
||||
list, err := repo.Index().Lookup(id, t)
|
||||
if err != nil {
|
||||
return err
|
||||
continue
|
||||
}
|
||||
blob := list[0]
|
||||
|
||||
buf := make([]byte, blob.Length)
|
||||
data, err := repo.LoadBlob(id, pack.Data, buf)
|
||||
data, err := repo.LoadBlob(id, t, buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = os.Stdout.Write(data)
|
||||
return err
|
||||
}
|
||||
|
||||
return errors.New("blob not found")
|
||||
|
||||
case "tree":
|
||||
debug.Log("cat", "cat tree %v", id.Str())
|
||||
|
Loading…
Reference in New Issue
Block a user