mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-06 00:03:38 +00:00
Don't add corrupt chunks to verified_chunks
When -persist is specified, the chunk downloader may return the chunk even if the chunk is corrupt. We use the chunk.isBroken flag to detect this situation.
This commit is contained in:
@@ -1083,20 +1083,23 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe
|
|||||||
if chunk == nil {
|
if chunk == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
chunkID := manager.config.GetChunkIDFromHash(chunkHashes[chunkIndex])
|
|
||||||
verifiedChunksLock.Lock()
|
|
||||||
verifiedChunks[chunkID] = startTime.Unix()
|
|
||||||
verifiedChunksLock.Unlock()
|
|
||||||
|
|
||||||
downloadedChunkSize := atomic.AddInt64(&totalDownloadedChunkSize, int64(chunk.GetLength()))
|
if !chunk.isBroken {
|
||||||
downloadedChunks := atomic.AddInt64(&totalDownloadedChunks, 1)
|
chunkID := manager.config.GetChunkIDFromHash(chunkHashes[chunkIndex])
|
||||||
|
verifiedChunksLock.Lock()
|
||||||
|
verifiedChunks[chunkID] = startTime.Unix()
|
||||||
|
verifiedChunksLock.Unlock()
|
||||||
|
|
||||||
elapsedTime := time.Now().Sub(startTime).Seconds()
|
downloadedChunkSize := atomic.AddInt64(&totalDownloadedChunkSize, int64(chunk.GetLength()))
|
||||||
speed := int64(float64(downloadedChunkSize) / elapsedTime)
|
downloadedChunks := atomic.AddInt64(&totalDownloadedChunks, 1)
|
||||||
remainingTime := int64(float64(totalChunks - downloadedChunks) / float64(downloadedChunks) * elapsedTime)
|
|
||||||
percentage := float64(downloadedChunks) / float64(totalChunks) * 100.0
|
elapsedTime := time.Now().Sub(startTime).Seconds()
|
||||||
LOG_INFO("VERIFY_PROGRESS", "Verified chunk %s (%d/%d), %sB/s %s %.1f%%",
|
speed := int64(float64(downloadedChunkSize) / elapsedTime)
|
||||||
chunkID, downloadedChunks, totalChunks, PrettySize(speed), PrettyTime(remainingTime), percentage)
|
remainingTime := int64(float64(totalChunks - downloadedChunks) / float64(downloadedChunks) * elapsedTime)
|
||||||
|
percentage := float64(downloadedChunks) / float64(totalChunks) * 100.0
|
||||||
|
LOG_INFO("VERIFY_PROGRESS", "Verified chunk %s (%d/%d), %sB/s %s %.1f%%",
|
||||||
|
chunkID, downloadedChunks, totalChunks, PrettySize(speed), PrettyTime(remainingTime), percentage)
|
||||||
|
}
|
||||||
|
|
||||||
manager.config.PutChunk(chunk)
|
manager.config.PutChunk(chunk)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user