Rename variables in fileBytesLeft
This commit is contained in:
parent
3507ff1a69
commit
4be8b12207
27
file.go
27
file.go
@ -54,22 +54,29 @@ func (f *File) bytesCompleted() int64 {
|
|||||||
return f.length - f.bytesLeft()
|
return f.length - f.bytesLeft()
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileBytesLeft(pieceSize int64, firstPieceIndex int, endPieceIndex int, fileOffset int64, fileLength int64, completedPieces bitmap.Bitmap) (left int64) {
|
func fileBytesLeft(
|
||||||
endPieceIndex--
|
torrentUsualPieceSize int64,
|
||||||
bitmap.Flip(completedPieces, firstPieceIndex+1, endPieceIndex).IterTyped(func(piece int) bool {
|
fileFirstPieceIndex int,
|
||||||
if piece >= endPieceIndex {
|
fileEndPieceIndex int,
|
||||||
|
fileTorrentOffset int64,
|
||||||
|
fileLength int64,
|
||||||
|
torrentCompletedPieces bitmap.Bitmap,
|
||||||
|
) (left int64) {
|
||||||
|
fileEndPieceIndex--
|
||||||
|
bitmap.Flip(torrentCompletedPieces, fileFirstPieceIndex+1, fileEndPieceIndex).IterTyped(func(piece int) bool {
|
||||||
|
if piece >= fileEndPieceIndex {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if piece > firstPieceIndex {
|
if piece > fileFirstPieceIndex {
|
||||||
left += pieceSize
|
left += torrentUsualPieceSize
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
if !completedPieces.Get(firstPieceIndex) {
|
if !torrentCompletedPieces.Get(fileFirstPieceIndex) {
|
||||||
left += pieceSize - (fileOffset % pieceSize)
|
left += torrentUsualPieceSize - (fileTorrentOffset % torrentUsualPieceSize)
|
||||||
}
|
}
|
||||||
if !completedPieces.Get(endPieceIndex) {
|
if !torrentCompletedPieces.Get(fileEndPieceIndex) {
|
||||||
left += (fileOffset + fileLength) % pieceSize
|
left += (fileTorrentOffset + fileLength) % torrentUsualPieceSize
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user