Run runs the complete snapshot and repository maintenance.
(ctx context.Context, dr repo.DirectRepositoryWriter, mode maintenance.Mode, force bool, safety maintenance.SafetyParameters)
| 16 | |
| 17 | // Run runs the complete snapshot and repository maintenance. |
| 18 | func Run(ctx context.Context, dr repo.DirectRepositoryWriter, mode maintenance.Mode, force bool, safety maintenance.SafetyParameters) error { |
| 19 | if dr.ClientOptions().ReadOnly { |
| 20 | return ErrReadonly |
| 21 | } |
| 22 | |
| 23 | dr.LogManager().Enable() |
| 24 | |
| 25 | //nolint:wrapcheck |
| 26 | return maintenance.RunExclusive(ctx, dr, mode, force, |
| 27 | func(ctx context.Context, runParams maintenance.RunParameters) error { |
| 28 | // run snapshot GC before full maintenance |
| 29 | if runParams.Mode == maintenance.ModeFull { |
| 30 | if err := snapshotgc.Run(ctx, dr, true, safety, runParams.MaintenanceStartTime); err != nil { |
| 31 | return errors.Wrap(err, "snapshot GC failure") |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | //nolint:wrapcheck |
| 36 | return maintenance.Run(ctx, runParams, safety) |
| 37 | }) |
| 38 | } |