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
|
||||
}
|
||||
|
||||
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)
|
||||
return err
|
||||
|
||||
case "blob":
|
||||
list, err := repo.Index().Lookup(id, pack.Data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
blob := list[0]
|
||||
for _, t := range []pack.BlobType{pack.Data, pack.Tree} {
|
||||
list, err := repo.Index().Lookup(id, t)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
blob := list[0]
|
||||
|
||||
buf := make([]byte, blob.Length)
|
||||
data, err := repo.LoadBlob(id, pack.Data, buf)
|
||||
if err != nil {
|
||||
buf := make([]byte, blob.Length)
|
||||
data, err := repo.LoadBlob(id, t, buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = os.Stdout.Write(data)
|
||||
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 a new issue