mirror of https://github.com/restic/restic.git
migrate: Cleanup option to request repository check
This commit is contained in:
parent
0cb6b3d80a
commit
5eba1217e7
|
@ -84,8 +84,7 @@ func applyMigrations(opts MigrateOptions, gopts GlobalOptions, repo restic.Repos
|
||||||
Warnf("check for migration %v failed, continuing anyway\n", m.Name())
|
Warnf("check for migration %v failed, continuing anyway\n", m.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
repoCheckOpts := m.RepoCheckOptions()
|
if m.RepoCheck() {
|
||||||
if repoCheckOpts != nil {
|
|
||||||
Printf("checking repository integrity...\n")
|
Printf("checking repository integrity...\n")
|
||||||
|
|
||||||
checkOptions := CheckOptions{}
|
checkOptions := CheckOptions{}
|
||||||
|
|
|
@ -6,15 +6,12 @@ import (
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RepositoryCheckOptions struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Migration implements a data migration.
|
// Migration implements a data migration.
|
||||||
type Migration interface {
|
type Migration interface {
|
||||||
// Check returns true if the migration can be applied to a repo.
|
// Check returns true if the migration can be applied to a repo.
|
||||||
Check(context.Context, restic.Repository) (bool, error)
|
Check(context.Context, restic.Repository) (bool, error)
|
||||||
|
|
||||||
RepoCheckOptions() *RepositoryCheckOptions
|
RepoCheck() bool
|
||||||
|
|
||||||
// Apply runs the migration.
|
// Apply runs the migration.
|
||||||
Apply(context.Context, restic.Repository) error
|
Apply(context.Context, restic.Repository) error
|
||||||
|
|
|
@ -37,8 +37,8 @@ func (m *S3Layout) Check(ctx context.Context, repo restic.Repository) (bool, err
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *S3Layout) RepoCheckOptions() *RepositoryCheckOptions {
|
func (m *S3Layout) RepoCheck() bool {
|
||||||
return nil
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func retry(max int, fail func(err error), f func() error) error {
|
func retry(max int, fail func(err error), f func() error) error {
|
||||||
|
|
|
@ -50,8 +50,8 @@ func (*UpgradeRepoV2) Check(ctx context.Context, repo restic.Repository) (bool,
|
||||||
return isV1, nil
|
return isV1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*UpgradeRepoV2) RepoCheckOptions() *RepositoryCheckOptions {
|
func (*UpgradeRepoV2) RepoCheck() bool {
|
||||||
return &RepositoryCheckOptions{}
|
return true
|
||||||
}
|
}
|
||||||
func (*UpgradeRepoV2) upgrade(ctx context.Context, repo restic.Repository) error {
|
func (*UpgradeRepoV2) upgrade(ctx context.Context, repo restic.Repository) error {
|
||||||
h := restic.Handle{Type: restic.ConfigFile}
|
h := restic.Handle{Type: restic.ConfigFile}
|
||||||
|
|
Loading…
Reference in New Issue