ValidateChunkSize validate the chunk size
(filePath string, fileChunkSizeInMB uint64)
| 81 | |
| 82 | // ValidateChunkSize validate the chunk size |
| 83 | func 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 | |
| 108 | func minUint64(a, b uint64) uint64 { |
| 109 | if a < b { |
no test coverage detected