mirror of
https://github.com/restic/restic.git
synced 2025-06-10 21:18:28 +00:00
debug: extract examinePack function
This commit is contained in:
parent
84491ff40b
commit
096f15db5c
@ -426,8 +426,14 @@ func runDebugExamine(gopts GlobalOptions, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
blobsLoaded := false
|
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
|
examinePack(gopts.ctx, repo, name)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func examinePack(ctx context.Context, repo restic.Repository, name string) {
|
||||||
|
blobsLoaded := false
|
||||||
fmt.Printf("examine %v\n", name)
|
fmt.Printf("examine %v\n", name)
|
||||||
id, err := restic.ParseID(name)
|
id, err := restic.ParseID(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -438,14 +444,14 @@ func runDebugExamine(gopts GlobalOptions, args []string) error {
|
|||||||
Type: restic.PackFile,
|
Type: restic.PackFile,
|
||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
fi, err := repo.Backend().Stat(gopts.ctx, h)
|
fi, err := repo.Backend().Stat(ctx, h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(" file size is %v\n", fi.Size)
|
fmt.Printf(" file size is %v\n", fi.Size)
|
||||||
|
|
||||||
buf, err := backend.LoadAll(gopts.ctx, nil, repo.Backend(), h)
|
buf, err := backend.LoadAll(ctx, nil, repo.Backend(), h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
}
|
}
|
||||||
@ -507,7 +513,7 @@ func runDebugExamine(gopts GlobalOptions, args []string) error {
|
|||||||
list = append(list, b.Blob)
|
list = append(list, b.Blob)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = loadBlobs(gopts.ctx, repo, name, list)
|
err = loadBlobs(ctx, repo, name, list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
} else {
|
} else {
|
||||||
@ -518,10 +524,10 @@ func runDebugExamine(gopts GlobalOptions, args []string) error {
|
|||||||
fmt.Printf(" ========================================\n")
|
fmt.Printf(" ========================================\n")
|
||||||
fmt.Printf(" inspect the pack itself\n")
|
fmt.Printf(" inspect the pack itself\n")
|
||||||
|
|
||||||
blobs, _, err := pack.List(repo.Key(), restic.ReaderAt(gopts.ctx, repo.Backend(), h), fi.Size)
|
blobs, _, err := pack.List(repo.Key(), restic.ReaderAt(ctx, repo.Backend(), h), fi.Size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error for pack %v: %v\n", id.Str(), err)
|
fmt.Fprintf(os.Stderr, "error for pack %v: %v\n", id.Str(), err)
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// track current size and offset
|
// track current size and offset
|
||||||
@ -552,11 +558,9 @@ func runDebugExamine(gopts GlobalOptions, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !blobsLoaded {
|
if !blobsLoaded {
|
||||||
err = loadBlobs(gopts.ctx, repo, name, blobs)
|
err = loadBlobs(ctx, repo, name, blobs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user