1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-20 18:23:29 +00:00

Retry on authentication error for Google Drive

This commit is contained in:
Gilbert Chen
2017-07-02 20:49:56 -04:00
parent 817e36c7a6
commit 4291bc775b

View File

@@ -32,6 +32,7 @@ type GCDStorage struct {
idCacheLock *sync.Mutex idCacheLock *sync.Mutex
backoff int backoff int
isConnected bool
numberOfThreads int numberOfThreads int
TestMode bool TestMode bool
@@ -64,6 +65,12 @@ func (storage *GCDStorage) shouldRetry(err error) (bool, error) {
// User Rate Limit Exceeded // User Rate Limit Exceeded
message = "User Rate Limit Exceeded" message = "User Rate Limit Exceeded"
retry = true retry = true
} else if e.Code == 401 {
// Only retry on authorization error when storage has been connected before
if storage.isConnected {
message = "Authorization Error"
retry = true
}
} }
} else if e, ok := err.(*url.Error); ok { } else if e, ok := err.(*url.Error); ok {
message = e.Error() message = e.Error()
@@ -295,6 +302,8 @@ func CreateGCDStorage(tokenFile string, storagePath string, threads int) (storag
} }
} }
storage.isConnected = true
return storage, nil return storage, nil
} }