π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Store remote albums in local db
Neeraj Guptaed3d4edaadd2
diff --git a/pkg/collections.go b/pkg/collections.goindex d78d8a2dae..85d8582595 100644--- a/pkg/collections.go+++ b/pkg/collections.go@@ -3,6 +3,7 @@ package pkgimport (debuglog "cli-go/pkg/log""cli-go/pkg/model"+ "cli-go/utils/encoding""context""fmt""strconv"@@ -36,6 +37,11 @@ func (c *ClICtrl) syncRemoteCollections(ctx context.Context, info model.Account)if album.LastUpdatedAt > maxUpdated {maxUpdated = album.LastUpdatedAt}+ albumJson := encoding.MustMarshalJSON(album)+ err := c.PutValue(ctx, model.RemoteAlbums, []byte(strconv.FormatInt(album.ID, 10)), albumJson)+ if err != nil {+ return err+ }debuglog.PrintAlbum(album)}if maxUpdated > lastSyncTime {diff --git a/pkg/store.go b/pkg/store.goindex c75bbde51c..93456c3b31 100644--- a/pkg/store.go+++ b/pkg/store.go@@ -40,6 +40,15 @@ func (c *ClICtrl) PutConfigValue(ctx context.Context, key string, value []byte)return kvBucket.Put([]byte(key), value)})}+func (c *ClICtrl) PutValue(ctx context.Context, store model.PhotosStore, key []byte, value []byte) error {+ return c.DB.Update(func(tx *bolt.Tx) error {+ kvBucket, err := getAccountStore(ctx, tx, store)+ if err != nil {+ return err+ }+ return kvBucket.Put(key, value)+ })+}func getAccountStore(ctx context.Context, tx *bolt.Tx, storeType model.PhotosStore) (*bolt.Bucket, error) {accountId := ctx.Value("account_id").(string)diff --git a/utils/encoding/encoding.go b/utils/encoding/encoding.goindex b5cec0b5fb..a88eceff7c 100644--- a/utils/encoding/encoding.go+++ b/utils/encoding/encoding.go@@ -2,6 +2,7 @@ package encodingimport ("encoding/base64"+ "encoding/json")func DecodeBase64(s string) []byte {@@ -15,3 +16,11 @@ func DecodeBase64(s string) []byte {func EncodeBase64(b []byte) string {return base64.StdEncoding.EncodeToString(b)}++func MustMarshalJSON(v interface{}) []byte {+ b, err := json.Marshal(v)+ if err != nil {+ panic(err)+ }+ return b+}