MCPcopy
hub / github.com/kopia/kopia / maybeRunMaintenance

Method maybeRunMaintenance

cli/app.go:574–603  ·  view source on GitHub ↗
(ctx context.Context, rep repo.Repository)

Source from the content-addressed store, hash-verified

572}
573
574func (c *App) maybeRunMaintenance(ctx context.Context, rep repo.Repository) error {
575 if !c.enableAutomaticMaintenance {
576 return nil
577 }
578
579 if rep.ClientOptions().ReadOnly {
580 return nil
581 }
582
583 dr, ok := rep.(repo.DirectRepository)
584 if !ok {
585 return nil
586 }
587
588 err := repo.DirectWriteSession(ctx, dr, repo.WriteSessionOptions{
589 Purpose: "maybeRunMaintenance",
590 OnUpload: c.progress.UploadedBytes,
591 }, func(ctx context.Context, w repo.DirectRepositoryWriter) error {
592 return snapshotmaintenance.Run(ctx, w, maintenance.ModeAuto, false, maintenance.SafetyFull)
593 })
594
595 var noe maintenance.NotOwnedError
596
597 if errors.As(err, &noe) {
598 // do not report the NotOwnedError to the user since this is automatic maintenance.
599 return nil
600 }
601
602 return errors.Wrap(err, "error running maintenance")
603}
604
605func (c *App) dangerousCommand() {
606 if c.DangerousCommands != "enabled" {

Callers 1

repositoryActionMethod · 0.95

Calls 3

DirectWriteSessionFunction · 0.92
RunFunction · 0.92
ClientOptionsMethod · 0.65

Tested by

no test coverage detected