Debian Codegraph @

internal/migrations/upgrade_repo_v2.go

raw symbols SCIP
1 package migrations
2
3 import (
4 "context"
5 "fmt"
6
7 "github.com/restic/restic/internal/repository"
8 "github.com/restic/restic/internal/restic"
9 )
10
11 func init() {
12 register(&UpgradeRepoV2{})
13 }
14
15 type UpgradeRepoV2 struct{}
16
17 func (*UpgradeRepoV2) Name() string {
18 return "upgrade_repo_v2"
19 }
20
21 func (*UpgradeRepoV2) Desc() string {
22 return "upgrade a repository to version 2"
23 }
24
25 func (*UpgradeRepoV2) Check(_ context.Context, repo restic.Repository) (bool, string, error) {
26 isV1 := repo.Config().Version == 1
27 reason := ""
28 if !isV1 {
29 reason = fmt.Sprintf("repository is already upgraded to version %v", repo.Config().Version)
30 }
31 return isV1, reason, nil
32 }
33
34 func (*UpgradeRepoV2) RepoCheck() bool {
35 return true
36 }
37
38 func (m *UpgradeRepoV2) Apply(ctx context.Context, repo restic.Repository) error {
39 return repository.UpgradeRepo(ctx, repo.(*repository.Repository))
40 }