MCPcopy Index your code
hub / github.com/kopia/kopia / appendCompressionPolicyRows

Function appendCompressionPolicyRows

cli/command_policy_show.go:339–391  ·  view source on GitHub ↗
(rows []policyTableRow, p *policy.Policy, def *policy.Definition)

Source from the content-addressed store, hash-verified

337}
338
339func appendCompressionPolicyRows(rows []policyTableRow, p *policy.Policy, def *policy.Definition) []policyTableRow {
340 if p.CompressionPolicy.CompressorName == "" || p.CompressionPolicy.CompressorName == "none" {
341 rows = append(rows, policyTableRow{"Compression disabled.", "", ""})
342 return rows
343 }
344
345 rows = append(rows,
346 policyTableRow{"Compression:", "", ""},
347 policyTableRow{" Compressor:", string(p.CompressionPolicy.CompressorName), definitionPointToString(p.Target(), def.CompressionPolicy.CompressorName)})
348
349 switch {
350 case len(p.CompressionPolicy.OnlyCompress) > 0:
351 rows = append(rows, policyTableRow{
352 " Only compress files with the following extensions:", "",
353 definitionPointToString(p.Target(), def.CompressionPolicy.OnlyCompress),
354 })
355
356 for _, rule := range p.CompressionPolicy.OnlyCompress {
357 rows = append(rows, policyTableRow{" - " + rule, "", ""})
358 }
359
360 case len(p.CompressionPolicy.NeverCompress) > 0:
361 rows = append(rows, policyTableRow{
362 " Compress all files except the following extensions:", "",
363 definitionPointToString(p.Target(), def.CompressionPolicy.NeverCompress),
364 })
365
366 for _, rule := range p.CompressionPolicy.NeverCompress {
367 rows = append(rows, policyTableRow{" " + rule, "", ""})
368 }
369
370 default:
371 rows = append(rows, policyTableRow{" Compress files regardless of extensions.", "", ""})
372 }
373
374 switch {
375 case p.CompressionPolicy.MaxSize > 0:
376 rows = append(rows, policyTableRow{fmt.Sprintf(
377 " Only compress files between %v and %v.",
378 units.BytesString(p.CompressionPolicy.MinSize),
379 units.BytesString(p.CompressionPolicy.MaxSize)), "", ""})
380
381 case p.CompressionPolicy.MinSize > 0:
382 rows = append(rows, policyTableRow{fmt.Sprintf(
383 " Only compress files bigger than %v.",
384 units.BytesString(p.CompressionPolicy.MinSize)), "", ""})
385
386 default:
387 rows = append(rows, policyTableRow{" Compress files of all sizes.", "", ""})
388 }
389
390 return rows
391}
392
393func appendMetadataCompressionPolicyRows(rows []policyTableRow, p *policy.Policy, def *policy.Definition) []policyTableRow {
394 if p.MetadataCompressionPolicy.CompressorName == "" || p.MetadataCompressionPolicy.CompressorName == "none" {

Callers 2

printPolicyFunction · 0.85
populateRepositoryMethod · 0.85

Calls 3

BytesStringFunction · 0.92
definitionPointToStringFunction · 0.85
TargetMethod · 0.80

Tested by

no test coverage detected