MCPcopy
hub / github.com/syncthing/syncthing / blocksToSize

Function blocksToSize

lib/model/sharedpullerstate.go:454–462  ·  view source on GitHub ↗
(blocks, blocksInFile, blockSize int, fileSize int64)

Source from the content-addressed store, hash-verified

452}
453
454func 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}

Callers 1

ProgressMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected