forked from TrueCloudLab/restic
stats: Fix crash in blobs-per-file mode on missing blob
In a damaged repository with a missing blob, the error message tried to dereference the subtreeID field of the current node, which is a file however. Said field is set to nil for a file thus causing a segfault when dereferenced. Fix this by using the actual parentTreeID.
This commit is contained in:
parent
2b5a6d255a
commit
0ce81d88b6
2 changed files with 8 additions and 2 deletions
6
changelog/unreleased/pull-2668
Normal file
6
changelog/unreleased/pull-2668
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Bugfix: Don't abort the stats command when data blobs are missing
|
||||||
|
|
||||||
|
Runing the stats command in the blobs-per-file mode on a repository with
|
||||||
|
missing data blobs previously resulted in a crash.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/pull/2668
|
|
@ -194,7 +194,7 @@ func statsWalkSnapshot(ctx context.Context, snapshot *restic.Snapshot, repo rest
|
||||||
}
|
}
|
||||||
|
|
||||||
func statsWalkTree(repo restic.Repository, stats *statsContainer) walker.WalkFunc {
|
func statsWalkTree(repo restic.Repository, stats *statsContainer) walker.WalkFunc {
|
||||||
return func(_ restic.ID, npath string, node *restic.Node, nodeErr error) (bool, error) {
|
return func(parentTreeID restic.ID, npath string, node *restic.Node, nodeErr error) (bool, error) {
|
||||||
if nodeErr != nil {
|
if nodeErr != nil {
|
||||||
return true, nodeErr
|
return true, nodeErr
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ func statsWalkTree(repo restic.Repository, stats *statsContainer) walker.WalkFun
|
||||||
// is always a data blob since we're accessing it via a file's Content array
|
// is always a data blob since we're accessing it via a file's Content array
|
||||||
blobSize, found := repo.LookupBlobSize(blobID, restic.DataBlob)
|
blobSize, found := repo.LookupBlobSize(blobID, restic.DataBlob)
|
||||||
if !found {
|
if !found {
|
||||||
return true, fmt.Errorf("blob %s not found for tree %s", blobID, *node.Subtree)
|
return true, fmt.Errorf("blob %s not found for tree %s", blobID, parentTreeID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// count the blob's size, then add this blob by this
|
// count the blob's size, then add this blob by this
|
||||||
|
|
Loading…
Reference in a new issue