mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-06 00:03:38 +00:00
Merge pull request #562 from gilbertchen/azure_retry
Retry on broken pipe in Azure backend
This commit is contained in:
@@ -166,9 +166,21 @@ func (storage *AzureStorage) DownloadFile(threadIndex int, filePath string, chun
|
|||||||
|
|
||||||
// UploadFile writes 'content' to the file at 'filePath'.
|
// UploadFile writes 'content' to the file at 'filePath'.
|
||||||
func (storage *AzureStorage) UploadFile(threadIndex int, filePath string, content []byte) (err error) {
|
func (storage *AzureStorage) UploadFile(threadIndex int, filePath string, content []byte) (err error) {
|
||||||
reader := CreateRateLimitedReader(content, storage.UploadRateLimit/len(storage.containers))
|
|
||||||
blob := storage.containers[threadIndex].GetBlobReference(filePath)
|
tries := 0
|
||||||
return blob.CreateBlockBlobFromReader(reader, nil)
|
|
||||||
|
for {
|
||||||
|
reader := CreateRateLimitedReader(content, storage.UploadRateLimit/len(storage.containers))
|
||||||
|
blob := storage.containers[threadIndex].GetBlobReference(filePath)
|
||||||
|
err = blob.CreateBlockBlobFromReader(reader, nil)
|
||||||
|
|
||||||
|
if err == nil || !strings.Contains(err.Error(), "write: broken pipe") || tries >= 3 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO("AZURE_RETRY", "Connection unexpectedly terminated: %v; retrying", err)
|
||||||
|
tries++
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user