mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-15 07:43:21 +00:00
Skipped chunks should not be counted in order to get accurate download percentage
This commit is contained in:
@@ -174,7 +174,7 @@ func (downloader *ChunkDownloader) Prefetch(file *Entry) {
|
|||||||
// Reclaim releases the downloaded chunk to the chunk pool
|
// Reclaim releases the downloaded chunk to the chunk pool
|
||||||
func (downloader *ChunkDownloader) Reclaim(chunkIndex int) {
|
func (downloader *ChunkDownloader) Reclaim(chunkIndex int) {
|
||||||
|
|
||||||
if downloader.lastChunkIndex == chunkIndex {
|
if downloader.lastChunkIndex >= chunkIndex {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,13 +187,20 @@ func (downloader *ChunkDownloader) Reclaim(chunkIndex int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i := downloader.lastChunkIndex; i < chunkIndex; i++ {
|
||||||
|
// These chunks are never downloaded if 'isDownloading' is false; note that 'isDownloading' isn't reset to
|
||||||
|
// false after a chunk has been downloaded
|
||||||
|
if !downloader.taskList[i].isDownloading {
|
||||||
|
atomic.AddInt64(&downloader.totalChunkSize, -int64(downloader.taskList[i].chunkLength))
|
||||||
|
}
|
||||||
|
}
|
||||||
downloader.lastChunkIndex = chunkIndex
|
downloader.lastChunkIndex = chunkIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForChunk waits until the specified chunk is ready
|
// WaitForChunk waits until the specified chunk is ready
|
||||||
func (downloader *ChunkDownloader) WaitForChunk(chunkIndex int) (chunk *Chunk) {
|
func (downloader *ChunkDownloader) WaitForChunk(chunkIndex int) (chunk *Chunk) {
|
||||||
|
|
||||||
// Reclain any chunk not needed
|
// Reclaim any chunk not needed
|
||||||
downloader.Reclaim(chunkIndex)
|
downloader.Reclaim(chunkIndex)
|
||||||
|
|
||||||
// If we haven't started download the specified chunk, download it now
|
// If we haven't started download the specified chunk, download it now
|
||||||
|
|||||||
Reference in New Issue
Block a user