feat(backends/s3): add warmup support for check command (#5248)

This commit is contained in:
Gilbert Gilb's authored and GitHub committed 2026-06-25 20:46:55 +02:00
1 parent 4e8eea7ab4
commit db03aed816
9 files changed
+76 -16

No files matched your search

+25 -6
View File
@@ -12,6 +12,7 @@ import (
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/feature"
"github.com/restic/restic/internal/repository/hashing"
"github.com/restic/restic/internal/repository/index"
"github.com/restic/restic/internal/repository/pack"
@@ -243,7 +244,7 @@ func (c *Checker) Packs(ctx context.Context, errChan chan<- error) {
}
// ReadPacks loads data from specified packs and checks the integrity.
func (c *Checker) ReadPacks(ctx context.Context, filter func(packs map[restic.ID]int64) map[restic.ID]int64, p restic.Counter, errChan chan<- error) {
func (c *Checker) ReadPacks(ctx context.Context, filter func(packs map[restic.ID]int64) map[restic.ID]int64, printer restic.Printer, errChan chan<- error) {
defer close(errChan)
// compute pack size using index entries
@@ -253,7 +254,30 @@ func (c *Checker) ReadPacks(ctx context.Context, filter func(packs map[restic.ID
return
}
packs = filter(packs)
p := printer.NewCounter("packs")
p.SetMax(uint64(len(packs)))
defer p.Done()
packSet := restic.NewIDSet()
for pack := range packs {
packSet.Insert(pack)
}
if feature.Flag.Enabled(feature.S3Restore) {
job, err := c.repo.StartWarmup(ctx, packSet)
if err != nil {
errChan <- err
return
}
if job.HandleCount() != 0 {
printer.P("warming up %d packs from cold storage, this may take a while...", job.HandleCount())
if err := job.Wait(ctx); err != nil {
errChan <- err
return
}
}
}
g, ctx := errgroup.WithContext(ctx)
type checkTask struct {
@@ -302,11 +326,6 @@ func (c *Checker) ReadPacks(ctx context.Context, filter func(packs map[restic.ID
})
}
packSet := restic.NewIDSet()
for pack := range packs {
packSet.Insert(pack)
}
// push packs to ch
for pbs := range c.repo.listPacksFromIndex(ctx, packSet) {
size := packs[pbs.PackID]