forked from TrueCloudLab/restic
commit
6f5bf45212
1 changed files with 19 additions and 10 deletions
|
@ -157,24 +157,33 @@ func (cmd CmdCat) Execute(args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hash := backend.Hash(buf)
|
||||||
|
if !hash.Equal(id) {
|
||||||
|
fmt.Fprintf(cmd.global.stderr, "Warning: hash of data does not match ID, want\n %v\ngot:\n %v\n", id.String(), hash.String())
|
||||||
|
}
|
||||||
|
|
||||||
_, err = os.Stdout.Write(buf)
|
_, err = os.Stdout.Write(buf)
|
||||||
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())
|
||||||
|
|
Loading…
Reference in a new issue