From 5eba1217e73858fd33593b16595afa59b6dc9831 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 4 Jun 2022 23:45:00 +0200 Subject: [PATCH] migrate: Cleanup option to request repository check --- cmd/restic/cmd_migrate.go | 3 +-- internal/migrations/interface.go | 5 +---- internal/migrations/s3_layout.go | 4 ++-- internal/migrations/upgrade_repo_v2.go | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cmd/restic/cmd_migrate.go b/cmd/restic/cmd_migrate.go index 10d78b0ca..c8f0e9478 100644 --- a/cmd/restic/cmd_migrate.go +++ b/cmd/restic/cmd_migrate.go @@ -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{} diff --git a/internal/migrations/interface.go b/internal/migrations/interface.go index eb0a8e60c..99100bce3 100644 --- a/internal/migrations/interface.go +++ b/internal/migrations/interface.go @@ -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 diff --git a/internal/migrations/s3_layout.go b/internal/migrations/s3_layout.go index b64c3b073..0cfd40e60 100644 --- a/internal/migrations/s3_layout.go +++ b/internal/migrations/s3_layout.go @@ -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 { diff --git a/internal/migrations/upgrade_repo_v2.go b/internal/migrations/upgrade_repo_v2.go index 86abeaeff..acef8e0fa 100644 --- a/internal/migrations/upgrade_repo_v2.go +++ b/internal/migrations/upgrade_repo_v2.go @@ -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}