MCPcopy
hub / github.com/kopia/kopia / applyOptionalInt64MiB

Function applyOptionalInt64MiB

cli/command_policy_set.go:222–254  ·  view source on GitHub ↗
(ctx context.Context, desc string, val **policy.OptionalInt64, str string, changeCount *int)

Source from the content-addressed store, hash-verified

220}
221
222func applyOptionalInt64MiB(ctx context.Context, desc string, val **policy.OptionalInt64, str string, changeCount *int) error {
223 if str == "" {
224 // not changed
225 return nil
226 }
227
228 if str == inheritPolicyString || str == defaultPolicyString {
229 *changeCount++
230
231 log(ctx).Infof(" - resetting %q to a default value inherited from parent.", desc)
232
233 *val = nil
234
235 return nil
236 }
237
238 v, err := strconv.ParseInt(str, 10, 32)
239 if err != nil {
240 return errors.Wrapf(err, "can't parse the %v %q", desc, str)
241 }
242
243 // convert MiB to bytes
244 v *= 1 << 20 //nolint:mnd
245
246 i := policy.OptionalInt64(v)
247 *changeCount++
248
249 log(ctx).Infof(" - setting %q to %v.", desc, units.BytesString(v))
250
251 *val = &i
252
253 return nil
254}
255
256func applyPolicyNumber64(ctx context.Context, desc string, val *int64, str string, changeCount *int) error {
257 if str == "" {

Callers 1

Calls 2

OptionalInt64TypeAlias · 0.92
BytesStringFunction · 0.92

Tested by

no test coverage detected