mirror of
https://github.com/jkl1337/duplicacy.git
synced 2026-01-04 20:54:44 -06:00
Merge pull request #214 from macdanny/issue-207-retry-download
Retry downloads with corrupted content up to three times.
This commit is contained in:
@@ -324,22 +324,39 @@ func (downloader *ChunkDownloader) Download(threadIndex int, task ChunkDownloadT
|
|||||||
LOG_DEBUG("CHUNK_FOSSIL", "Chunk %s has been marked as a fossil", chunkID)
|
LOG_DEBUG("CHUNK_FOSSIL", "Chunk %s has been marked as a fossil", chunkID)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = downloader.storage.DownloadFile(threadIndex, chunkPath, chunk)
|
const MaxDownloadAttempts = 3
|
||||||
if err != nil {
|
for downloadAttempt := 0;; downloadAttempt++ {
|
||||||
LOG_ERROR("UPLOAD_FATAL", "Failed to download the chunk %s: %v", chunkID, err)
|
err = downloader.storage.DownloadFile(threadIndex, chunkPath, chunk)
|
||||||
return false
|
if err != nil {
|
||||||
}
|
LOG_ERROR("UPLOAD_FATAL", "Failed to download the chunk %s: %v", chunkID, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
err = chunk.Decrypt(downloader.config.ChunkKey, task.chunkHash)
|
err = chunk.Decrypt(downloader.config.ChunkKey, task.chunkHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LOG_ERROR("UPLOAD_CHUNK", "Failed to decrypt the chunk %s: %v", chunkID, err)
|
if downloadAttempt < MaxDownloadAttempts {
|
||||||
return false
|
LOG_WARN("RETRY_DOWNLOAD", "Failed to decrypt the chunk %s: %v", chunkID, err)
|
||||||
}
|
chunk.Reset(false)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
LOG_ERROR("UPLOAD_CHUNK", "Failed to decrypt the chunk %s: %v", chunkID, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
actualChunkID := chunk.GetID()
|
actualChunkID := chunk.GetID()
|
||||||
if actualChunkID != chunkID {
|
if actualChunkID != chunkID {
|
||||||
LOG_FATAL("UPLOAD_CORRUPTED", "The chunk %s has a hash id of %s", chunkID, actualChunkID)
|
if downloadAttempt < MaxDownloadAttempts {
|
||||||
return false
|
LOG_WARN("RETRY_DOWNLOAD", "The chunk %s has a hash id of %s", chunkID, actualChunkID)
|
||||||
|
chunk.Reset(false)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
LOG_FATAL("UPLOAD_CORRUPTED", "The chunk %s has a hash id of %s", chunkID, actualChunkID)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(cachedPath) > 0 {
|
if len(cachedPath) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user