π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Auto retry export on collection failure
Neeraj Gupta6f11aa75b626
diff --git a/pkg/model/errors.go b/pkg/model/errors.goindex 7f041ef6e4..d8f61d275b 100644--- a/pkg/model/errors.go+++ b/pkg/model/errors.go@@ -1,5 +1,13 @@package model-import "errors"+import (+ "errors"+ "strings"+)var ErrDecryption = errors.New("error while decrypting the file")++func ShouldRetrySync(err error) bool {+ return strings.Contains(err.Error(), "read tcp") ||+ strings.Contains(err.Error(), "dial tcp")+}diff --git a/pkg/model/remote.go b/pkg/model/remote.goindex 186edfb43b..75ff88c430 100644--- a/pkg/model/remote.go+++ b/pkg/model/remote.go@@ -142,9 +142,6 @@ func (r *RemoteFile) GetModificationTime() time.Time {}func (r *RemoteFile) GetLatlong() *export.Location {- if r.ID == 10698020 {- fmt.Println("found 10698020")- }if r.PublicMetadata != nil {// check if lat and long key existsif lat, ok := r.PublicMetadata["lat"]; ok {diff --git a/pkg/sync.go b/pkg/sync.goindex d54ef08403..6aee7cbb75 100644--- a/pkg/sync.go+++ b/pkg/sync.go@@ -7,9 +7,9 @@ import ("github.com/ente-io/cli/internal""github.com/ente-io/cli/internal/api""github.com/ente-io/cli/pkg/model"- "log"-bolt "go.etcd.io/bbolt"+ "log"+ "time")func (c *ClICtrl) Export() error {@@ -37,12 +37,23 @@ func (c *ClICtrl) Export() error {continue}log.Println("start sync")- err = c.SyncAccount(account)- if err != nil {- fmt.Printf("Error syncing account %s: %s\n", account.Email, err)- return err- } else {- log.Println("sync done")+ retryCount := 0+ for {+ err = c.SyncAccount(account)+ if err != nil {+ if model.ShouldRetrySync(err) && retryCount < 20 {+ retryCount = retryCount + 1+ timeInSecond := time.Duration(retryCount*10) * time.Second+ log.Printf("Connection err, waiting for %s before trying again", timeInSecond.String())+ time.Sleep(timeInSecond)+ continue+ }+ fmt.Printf("Error syncing account %s: %s\n", account.Email, err)+ return err+ } else {+ log.Println("sync done")+ break+ }}}@@ -63,10 +74,12 @@ func (c *ClICtrl) SyncAccount(account model.Account) error {err = c.fetchRemoteCollections(ctx)if err != nil {log.Printf("Error fetching collections: %s", err)+ return err}err = c.fetchRemoteFiles(ctx)if err != nil {log.Printf("Error fetching files: %s", err)+ return err}err = c.createLocalFolderForRemoteAlbums(ctx, account)if err != nil {