mirror of
https://github.com/kopia/kopia.git
synced 2025-12-23 22:57:50 -05:00
Use non-formatting logging functions for message without formatting.
For example, `log.Info("message")` instead of `log.Infof("message")`
Configure linter for printf-like functions
39 lines
814 B
Go
39 lines
814 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
type commandRepositoryThrottleSet struct {
|
|
cts commonThrottleSet
|
|
}
|
|
|
|
func (c *commandRepositoryThrottleSet) setup(svc appServices, parent commandParent) {
|
|
cmd := parent.Command("set", "Set throttling parameters for a repository")
|
|
c.cts.setup(cmd)
|
|
|
|
cmd.Action(svc.directRepositoryWriteAction(c.run))
|
|
}
|
|
|
|
func (c *commandRepositoryThrottleSet) run(ctx context.Context, rep repo.DirectRepositoryWriter) error {
|
|
thr := rep.Throttler()
|
|
limits := thr.Limits()
|
|
|
|
var changeCount int
|
|
|
|
if err := c.cts.apply(ctx, &limits, &changeCount); err != nil {
|
|
return err
|
|
}
|
|
|
|
if changeCount == 0 {
|
|
log(ctx).Info("No changes made.")
|
|
return nil
|
|
}
|
|
|
|
return errors.Wrap(rep.Throttler().SetLimits(limits), "error setting limits")
|
|
}
|