restic check and restic repair packs: treat missing packfiles the same as damaged and truncated packfiles (#21845)

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
This commit is contained in:
Winfried Plappert
2026-06-28 11:09:42 +01:00
committed by GitHub
parent e4056e70a8
commit 75de8b54e6
11 changed files with 122 additions and 21 deletions
+2 -1
View File
@@ -57,6 +57,7 @@ type ErrPackMetadata struct {
ID restic.ID
Orphaned bool
Truncated bool
Missing bool
Err error
}
@@ -218,7 +219,7 @@ func (c *Checker) Packs(ctx context.Context, errChan chan<- error) {
select {
case <-ctx.Done():
return
case errChan <- &ErrPackMetadata{ID: id, Err: errors.New("does not exist")}:
case errChan <- &ErrPackMetadata{ID: id, Missing: true, Err: errors.New("does not exist")}:
}
continue
}
+7 -1
View File
@@ -65,7 +65,13 @@ func RepairPacks(ctx context.Context, repo *Repository, ids restic.IDSet, printe
printer.P("removing salvaged pack files")
// if we fail to delete the damaged pack files, then prune will remove them later on
bar = printer.NewCounter("files deleted")
_ = restic.ParallelRemove(ctx, &internalRepository{repo}, ids, restic.PackFile, nil, bar)
_ = restic.ParallelRemove(ctx, &internalRepository{repo}, ids, restic.PackFile, func(id restic.ID, err error) error {
// only log errors while deleting pack files
if err != nil {
printer.E("failed to delete pack file %v: %v", id, err)
}
return nil
}, bar)
bar.Done()
return nil