Merge pull request #3784 from MichaelEischer/cleanup-migrate-check

migrate: Cleanup option to request repository check
This commit is contained in:
Alexander Neumann 2022-06-05 17:37:45 +02:00 committed by GitHub
commit 7d64aa7f57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 10 deletions

View file

@ -84,8 +84,7 @@ func applyMigrations(opts MigrateOptions, gopts GlobalOptions, repo restic.Repos
Warnf("check for migration %v failed, continuing anyway\n", m.Name())
}
repoCheckOpts := m.RepoCheckOptions()
if repoCheckOpts != nil {
if m.RepoCheck() {
Printf("checking repository integrity...\n")
checkOptions := CheckOptions{}

View file

@ -6,15 +6,12 @@ import (
"github.com/restic/restic/internal/restic"
)
type RepositoryCheckOptions struct {
}
// Migration implements a data migration.
type Migration interface {
// Check returns true if the migration can be applied to a repo.
Check(context.Context, restic.Repository) (bool, error)
RepoCheckOptions() *RepositoryCheckOptions
RepoCheck() bool
// Apply runs the migration.
Apply(context.Context, restic.Repository) error

View file

@ -37,8 +37,8 @@ func (m *S3Layout) Check(ctx context.Context, repo restic.Repository) (bool, err
return true, nil
}
func (m *S3Layout) RepoCheckOptions() *RepositoryCheckOptions {
return nil
func (m *S3Layout) RepoCheck() bool {
return false
}
func retry(max int, fail func(err error), f func() error) error {

View file

@ -50,8 +50,8 @@ func (*UpgradeRepoV2) Check(ctx context.Context, repo restic.Repository) (bool,
return isV1, nil
}
func (*UpgradeRepoV2) RepoCheckOptions() *RepositoryCheckOptions {
return &RepositoryCheckOptions{}
func (*UpgradeRepoV2) RepoCheck() bool {
return true
}
func (*UpgradeRepoV2) upgrade(ctx context.Context, repo restic.Repository) error {
h := restic.Handle{Type: restic.ConfigFile}