MCPcopy Create free account
hub / github.com/cloudfoundry/multiapps-cli-plugin / ValidateChunkSize

Function ValidateChunkSize

util/file_splitter.go:83–106  ·  view source on GitHub ↗

ValidateChunkSize validate the chunk size

(filePath string, fileChunkSizeInMB uint64)

Source from the content-addressed store, hash-verified

81
82// ValidateChunkSize validate the chunk size
83func ValidateChunkSize(filePath string, fileChunkSizeInMB uint64) error {
84 if fileChunkSizeInMB == 0 {
85 return nil
86 }
87
88 if fileChunkSizeInMB == properties.DefaultUploadChunkSizeInMB {
89 return nil
90 }
91
92 fileInfo, err := os.Stat(filePath)
93 if err != nil {
94 return err
95 }
96
97 var fileSize = uint64(fileInfo.Size())
98 var fileSizeInMb = toMegabytes(fileSize)
99
100 var minFileChunkSizeInMb = uint64(math.Ceil(float64(fileSizeInMb) / float64(MaxFileChunkCount)))
101
102 if fileChunkSizeInMB < minFileChunkSizeInMb {
103 return fmt.Errorf("The specified chunk size (%d MB) is below the minimum chunk size (%d MB) for an archive with a size of %d MBs", fileChunkSizeInMB, minFileChunkSizeInMb, fileSizeInMb)
104 }
105 return nil
106}
107
108func minUint64(a, b uint64) uint64 {
109 if a < b {

Callers 1

uploadInChunksMethod · 0.92

Calls 3

toMegabytesFunction · 0.85
StatMethod · 0.80
SizeMethod · 0.80

Tested by

no test coverage detected