calBufferSize calculates the buffer size of bufio.Reader if the size < 4 * KB, use 4 * KB as the size of buffer in bufio.Reader if the size > 4 * KB, use the nearly blockSize buffer as the size of buffer in bufio.Reader
(size int)
| 124 | // if the size < 4 * KB, use 4 * KB as the size of buffer in bufio.Reader |
| 125 | // if the size > 4 * KB, use the nearly blockSize buffer as the size of buffer in bufio.Reader |
| 126 | func calBufferSize(size int) int { |
| 127 | blockSize := 4 * KB |
| 128 | if size < blockSize { |
| 129 | return blockSize |
| 130 | } |
| 131 | hasRest := (size%blockSize == 0) |
| 132 | if hasRest { |
| 133 | return (size/blockSize + 1) * blockSize |
| 134 | } |
| 135 | return size |
| 136 | } |
| 137 | |
| 138 | func (fr *fileRecovery) release() error { |
| 139 | if fr.closed { |