MCPcopy
hub / github.com/kopia/kopia / maybeAutoUpgradeRepository

Function maybeAutoUpgradeRepository

cli/auto_upgrade.go:12–36  ·  view source on GitHub ↗
(ctx context.Context, r repo.Repository)

Source from the content-addressed store, hash-verified

10)
11
12func maybeAutoUpgradeRepository(ctx context.Context, r repo.Repository) error {
13 // only upgrade repository when it's directly connected, not via API.
14 dr, _ := r.(repo.DirectRepository)
15 if dr == nil {
16 return nil
17 }
18
19 has, err := maintenance.HasParams(ctx, r)
20 if err != nil {
21 return errors.Wrap(err, "error looking for maintenance parameters")
22 }
23
24 if has {
25 return nil
26 }
27
28 log(ctx).Debug("Setting default maintenance parameters...")
29
30 //nolint:wrapcheck
31 return repo.DirectWriteSession(ctx, dr, repo.WriteSessionOptions{
32 Purpose: "setDefaultMaintenanceParameters",
33 }, func(ctx context.Context, w repo.DirectRepositoryWriter) error {
34 return setDefaultMaintenanceParameters(ctx, w)
35 })
36}
37
38func setDefaultMaintenanceParameters(ctx context.Context, rep repo.RepositoryWriter) error {
39 p := maintenance.DefaultParams()

Callers 1

runMethod · 0.85

Calls 3

HasParamsFunction · 0.92
DirectWriteSessionFunction · 0.92

Tested by

no test coverage detected