From 4291bc775b71c0149f6b4f67301818f56d59302e Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Sun, 2 Jul 2017 20:49:56 -0400 Subject: [PATCH] Retry on authentication error for Google Drive --- src/duplicacy_gcdstorage.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/duplicacy_gcdstorage.go b/src/duplicacy_gcdstorage.go index d51a3bc..ec46ac9 100644 --- a/src/duplicacy_gcdstorage.go +++ b/src/duplicacy_gcdstorage.go @@ -32,6 +32,7 @@ type GCDStorage struct { idCacheLock *sync.Mutex backoff int + isConnected bool numberOfThreads int TestMode bool @@ -64,6 +65,12 @@ func (storage *GCDStorage) shouldRetry(err error) (bool, error) { // User Rate Limit Exceeded message = "User Rate Limit Exceeded" 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 { message = e.Error() @@ -295,6 +302,8 @@ func CreateGCDStorage(tokenFile string, storagePath string, threads int) (storag } } + storage.isConnected = true + return storage, nil }