1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 15:57:07 +00:00

Merge pull request #3767 from MichaelEischer/fix-prune-empty-snapshot

prune: Fix crash on snapshot loading error
This commit is contained in:
Alexander Neumann 2022-05-29 16:52:45 +02:00 committed by GitHub
commit 74f7fe2b98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -621,15 +621,16 @@ func getUsedBlobs(gopts GlobalOptions, repo restic.Repository, ignoreSnapshots r
Verbosef("loading all snapshots...\n") Verbosef("loading all snapshots...\n")
err = restic.ForAllSnapshots(gopts.ctx, repo.Backend(), repo, ignoreSnapshots, err = restic.ForAllSnapshots(gopts.ctx, repo.Backend(), repo, ignoreSnapshots,
func(id restic.ID, sn *restic.Snapshot, err error) error { func(id restic.ID, sn *restic.Snapshot, err error) error {
debug.Log("add snapshot %v (tree %v, error %v)", id, *sn.Tree, err)
if err != nil { if err != nil {
debug.Log("failed to load snapshot %v (error %v)", id, err)
return err return err
} }
debug.Log("add snapshot %v (tree %v)", id, *sn.Tree)
snapshotTrees = append(snapshotTrees, *sn.Tree) snapshotTrees = append(snapshotTrees, *sn.Tree)
return nil return nil
}) })
if err != nil { if err != nil {
return nil, err return nil, errors.Fatalf("failed loading snapshot: %v", err)
} }
Verbosef("finding data that is still in use for %d snapshots\n", len(snapshotTrees)) Verbosef("finding data that is still in use for %d snapshots\n", len(snapshotTrees))