mirror of
https://github.com/restic/restic.git
synced 2025-12-12 06:41:54 +00:00
repository: add Checker() method to repository to replace unchecked cast
This commit is contained in:
@@ -33,10 +33,15 @@ type Checker struct {
|
||||
repo restic.Repository
|
||||
}
|
||||
|
||||
type checkerRepository interface {
|
||||
restic.Repository
|
||||
Checker() *repository.Checker
|
||||
}
|
||||
|
||||
// New returns a new checker which runs on repo.
|
||||
func New(repo restic.Repository, trackUnused bool) *Checker {
|
||||
func New(repo checkerRepository, trackUnused bool) *Checker {
|
||||
c := &Checker{
|
||||
Checker: repository.NewChecker(repo),
|
||||
Checker: repo.Checker(),
|
||||
repo: repo,
|
||||
trackUnused: trackUnused,
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ func TestCheckerModifiedData(t *testing.T) {
|
||||
|
||||
// loadTreesOnceRepository allows each tree to be loaded only once
|
||||
type loadTreesOnceRepository struct {
|
||||
restic.Repository
|
||||
*repository.Repository
|
||||
loadedTrees restic.IDSet
|
||||
mutex sync.Mutex
|
||||
DuplicateTree bool
|
||||
@@ -476,7 +476,7 @@ func TestCheckerNoDuplicateTreeDecodes(t *testing.T) {
|
||||
|
||||
// delayRepository delays read of a specific handle.
|
||||
type delayRepository struct {
|
||||
restic.Repository
|
||||
*repository.Repository
|
||||
DelayTree restic.ID
|
||||
UnblockChannel chan struct{}
|
||||
Unblocker sync.Once
|
||||
|
||||
@@ -3,12 +3,10 @@ package checker
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/internal/restic"
|
||||
)
|
||||
|
||||
// TestCheckRepo runs the checker on repo.
|
||||
func TestCheckRepo(t testing.TB, repo restic.Repository) {
|
||||
func TestCheckRepo(t testing.TB, repo checkerRepository) {
|
||||
chkr := New(repo, true)
|
||||
|
||||
hints, errs := chkr.LoadIndex(context.TODO(), nil)
|
||||
|
||||
Reference in New Issue
Block a user