forked from TrueCloudLab/restic
Merge pull request #3403 from MichaelEischer/fast-cat
cat: only load index if really necessary
This commit is contained in:
commit
2daf033156
1 changed files with 5 additions and 9 deletions
|
@ -69,7 +69,6 @@ func runCat(gopts GlobalOptions, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle all types that don't need an index
|
|
||||||
switch tpe {
|
switch tpe {
|
||||||
case "config":
|
case "config":
|
||||||
buf, err := json.MarshalIndent(repo.Config(), "", " ")
|
buf, err := json.MarshalIndent(repo.Config(), "", " ")
|
||||||
|
@ -142,15 +141,7 @@ func runCat(gopts GlobalOptions, args []string) error {
|
||||||
|
|
||||||
Println(string(buf))
|
Println(string(buf))
|
||||||
return nil
|
return nil
|
||||||
}
|
|
||||||
|
|
||||||
// load index, handle all the other types
|
|
||||||
err = repo.LoadIndex(gopts.ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
switch tpe {
|
|
||||||
case "pack":
|
case "pack":
|
||||||
h := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
h := restic.Handle{Type: restic.PackFile, Name: id.String()}
|
||||||
buf, err := backend.LoadAll(gopts.ctx, nil, repo.Backend(), h)
|
buf, err := backend.LoadAll(gopts.ctx, nil, repo.Backend(), h)
|
||||||
|
@ -167,6 +158,11 @@ func runCat(gopts GlobalOptions, args []string) error {
|
||||||
return err
|
return err
|
||||||
|
|
||||||
case "blob":
|
case "blob":
|
||||||
|
err = repo.LoadIndex(gopts.ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for _, t := range []restic.BlobType{restic.DataBlob, restic.TreeBlob} {
|
for _, t := range []restic.BlobType{restic.DataBlob, restic.TreeBlob} {
|
||||||
bh := restic.BlobHandle{ID: id, Type: t}
|
bh := restic.BlobHandle{ID: id, Type: t}
|
||||||
if !repo.Index().Has(bh) {
|
if !repo.Index().Has(bh) {
|
||||||
|
|
Loading…
Reference in a new issue