Function
blocksToSize
(blocks, blocksInFile, blockSize int, fileSize int64)
Source from the content-addressed store, hash-verified
| 452 | } |
| 453 | |
| 454 | func blocksToSize(blocks, blocksInFile, blockSize int, fileSize int64) int64 { |
| 455 | // The last/only block has somewhere between 1 and blockSize bytes. We do |
| 456 | // not know whether the smaller block is part of the blocks and use an |
| 457 | // estimate assuming a random chance that the small block is contained. |
| 458 | if blocksInFile == 0 { |
| 459 | return 0 |
| 460 | } |
| 461 | return int64(blocks)*int64(blockSize) - (int64(blockSize)-fileSize%int64(blockSize))*int64(blocks)/int64(blocksInFile) |
| 462 | } |
Tested by
no test coverage detected