mirror of
https://github.com/jkl1337/duplicacy.git
synced 2026-01-02 19:54:54 -06:00
Retry on unexpected EOF when dowloading files
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
package duplicacy
|
package duplicacy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -328,18 +329,24 @@ func (downloader *ChunkDownloader) Download(threadIndex int, task ChunkDownloadT
|
|||||||
for downloadAttempt := 0;; downloadAttempt++ {
|
for downloadAttempt := 0;; downloadAttempt++ {
|
||||||
err = downloader.storage.DownloadFile(threadIndex, chunkPath, chunk)
|
err = downloader.storage.DownloadFile(threadIndex, chunkPath, chunk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LOG_ERROR("UPLOAD_FATAL", "Failed to download the chunk %s: %v", chunkID, err)
|
if err == io.ErrUnexpectedEOF && downloadAttempt < MaxDownloadAttempts {
|
||||||
return false
|
LOG_WARN("DOWNLOAD_RETRY", "Failed to download the chunk %s: %v; retrying", chunkID, err)
|
||||||
|
chunk.Reset(false)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
LOG_ERROR("DOWNLOAD_CHUNK", "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 {
|
||||||
if downloadAttempt < MaxDownloadAttempts {
|
if downloadAttempt < MaxDownloadAttempts {
|
||||||
LOG_WARN("RETRY_DOWNLOAD", "Failed to decrypt the chunk %s: %v; retrying", chunkID, err)
|
LOG_WARN("DOWNLOAD_RETRY", "Failed to decrypt the chunk %s: %v; retrying", chunkID, err)
|
||||||
chunk.Reset(false)
|
chunk.Reset(false)
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("UPLOAD_CHUNK", "Failed to decrypt the chunk %s: %v", chunkID, err)
|
LOG_ERROR("DOWNLOAD_DECRYPT", "Failed to decrypt the chunk %s: %v", chunkID, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,11 +354,11 @@ func (downloader *ChunkDownloader) Download(threadIndex int, task ChunkDownloadT
|
|||||||
actualChunkID := chunk.GetID()
|
actualChunkID := chunk.GetID()
|
||||||
if actualChunkID != chunkID {
|
if actualChunkID != chunkID {
|
||||||
if downloadAttempt < MaxDownloadAttempts {
|
if downloadAttempt < MaxDownloadAttempts {
|
||||||
LOG_WARN("RETRY_DOWNLOAD", "The chunk %s has a hash id of %s; retrying", chunkID, actualChunkID)
|
LOG_WARN("DOWNLOAD_RETRY", "The chunk %s has a hash id of %s; retrying", chunkID, actualChunkID)
|
||||||
chunk.Reset(false)
|
chunk.Reset(false)
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
LOG_FATAL("UPLOAD_CORRUPTED", "The chunk %s has a hash id of %s", chunkID, actualChunkID)
|
LOG_FATAL("DOWNLOAD_CORRUPTED", "The chunk %s has a hash id of %s", chunkID, actualChunkID)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user