π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Store metadata as map for albums
Neeraj Gupta12ff1ee552cb
diff --git a/main.go b/main.goindex c5831e7666..be12a1ef59 100644--- a/main.go+++ b/main.go@@ -15,7 +15,7 @@ func main() {ctrl := pkg.ClICtrl{Client: api.NewClient(api.Params{Debug: false,- Host: "http://localhost:8080",+ //Host: "http://localhost:8080",}),DB: db,CliKey: secrets.GetOrCreateClISecret(),diff --git a/pkg/collections.go b/pkg/collections.goindex 4272ed910e..d8cca3e4a7 100644--- a/pkg/collections.go+++ b/pkg/collections.go@@ -9,6 +9,7 @@ import ("fmt""log""strconv"+ "time")func (c *ClICtrl) fetchRemoteCollections(ctx context.Context) error {@@ -64,9 +65,14 @@ func (c *ClICtrl) fetchRemoteFiles(ctx context.Context) error {}isFirstSync := lastSyncTime == 0for {+if lastSyncTime == album.LastUpdatedAt {break}+ if !isFirstSync {+ t := time.UnixMicro(lastSyncTime)+ log.Printf("Fetching files for album %s from %v\n", album.AlbumName, t)+ }files, hasMore, err := c.Client.GetFiles(ctx, album.ID, lastSyncTime)if err != nil {return errdiff --git a/pkg/log/debug_print.go b/pkg/log/debug_print.goindex 35ac29c38c..d161e5c520 100644--- a/pkg/log/debug_print.go+++ b/pkg/log/debug_print.go@@ -16,13 +16,13 @@ func PrintAlbum(a *model.Album) {}fmt.Printf(" Name: %s\n", a.AlbumName)if a.PrivateMeta != nil {- fmt.Printf("PrivateMeta: %s\n", *a.PrivateMeta)+ fmt.Printf("PrivateMeta: %s\n", a.PrivateMeta)}if a.PublicMeta != nil {- fmt.Printf("PublicMeta: %s\n", *a.PublicMeta)+ fmt.Printf("PublicMeta: %s\n", a.PublicMeta)}if a.SharedMeta != nil {- fmt.Printf("SharedMeta: %s\n", *a.SharedMeta)+ fmt.Printf("SharedMeta: %s\n", a.SharedMeta)}fmt.Printf("LastUpdatedAt: %d", a.LastUpdatedAt)fmt.Printf("\n=======")diff --git a/pkg/mappers.go b/pkg/mappers.goindex cd9b223b4b..49c839964a 100644--- a/pkg/mappers.go+++ b/pkg/mappers.go@@ -41,24 +41,30 @@ func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Colleif err != nil {return nil, err}- var val = string(encodedJsonBytes)- album.PrivateMeta = &val+ err = json.Unmarshal(encodedJsonBytes, &album.PrivateMeta)+ if err != nil {+ return nil, err+ }}if collection.PublicMagicMetadata != nil {_, encodedJsonBytes, err := enteCrypto.DecryptChaChaBase64(collection.PublicMagicMetadata.Data, collectionKey, collection.PublicMagicMetadata.Header)if err != nil {return nil, err}- var val = string(encodedJsonBytes)- album.PublicMeta = &val+ err = json.Unmarshal(encodedJsonBytes, &album.PublicMeta)+ if err != nil {+ return nil, err+ }}if album.IsShared && collection.SharedMagicMetadata != nil {_, encodedJsonBytes, err := enteCrypto.DecryptChaChaBase64(collection.SharedMagicMetadata.Data, collectionKey, collection.SharedMagicMetadata.Header)if err != nil {return nil, err}- var val = string(encodedJsonBytes)- album.SharedMeta = &val+ err = json.Unmarshal(encodedJsonBytes, &album.SharedMeta)+ if err != nil {+ return nil, err+ }}return &album, nil}@@ -82,7 +88,7 @@ func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.Album,photoFile.ThumbnailNonce = file.Thumbnail.DecryptionHeaderphotoFile.OwnerID = file.OwnerIDif file.Info != nil {- photoFile.PhotoInfo = model.PhotoInfo{+ photoFile.Info = model.PhotoInfo{FileSize: file.Info.FileSize,ThumbnailSize: file.Info.ThumbnailSize,}diff --git a/pkg/model/album.go b/pkg/model/album.goindex dc4b1742c8..203fe14495 100644--- a/pkg/model/album.go+++ b/pkg/model/album.go@@ -1,14 +1,14 @@package modeltype Album struct {- ID int64 `json:"id"`- OwnerID int64 `json:"ownerID"`- IsShared bool `json:"isShared"`- IsDeleted bool `json:"isDeleted"`- AlbumName string `json:"albumName"`- AlbumKey EncString `json:"albumKey"`- PublicMeta *string `json:"publicMeta"`- PrivateMeta *string `json:"privateMeta"`- SharedMeta *string `json:"sharedMeta"`- LastUpdatedAt int64 `json:"lastUpdatedAt"`+ ID int64 `json:"id"`+ OwnerID int64 `json:"ownerID"`+ IsShared bool `json:"isShared"`+ IsDeleted bool `json:"isDeleted"`+ AlbumName string `json:"albumName"`+ AlbumKey EncString `json:"albumKey"`+ PublicMeta map[string]interface{} `json:"publicMeta"`+ PrivateMeta map[string]interface{} `json:"privateMeta"`+ SharedMeta map[string]interface{} `json:"sharedMeta"`+ LastUpdatedAt int64 `json:"lastUpdatedAt"`}diff --git a/pkg/model/photo_file.go b/pkg/model/photo_file.goindex 467be6a2a5..f84c1556a5 100644--- a/pkg/model/photo_file.go+++ b/pkg/model/photo_file.go@@ -9,7 +9,7 @@ type PhotoFile struct {ThumbnailNonce string `json:"thumbnailNonce"`PrivateMetadata map[string]interface{} `json:"privateMetadata"`PublicMetadata map[string]interface{} `json:"publicMetadata"`- PhotoInfo PhotoInfo ``+ Info PhotoInfo `json:"info"`}type PhotoInfo struct {