Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Rename

Neeraj Gupta2b2c3f47d821
diff --git a/pkg/collections.go b/pkg/collections.go
index 3791149642..b2828d58d7 100644
--- a/pkg/collections.go
+++ b/pkg/collections.go
@@ -110,14 +110,14 @@ func (c *ClICtrl) fetchRemoteFiles(ctx context.Context) error {
return nil
}
-func (c *ClICtrl) getRemoteAlbums(ctx context.Context) ([]model.Album, error) {
- albums := make([]model.Album, 0)
+func (c *ClICtrl) getRemoteAlbums(ctx context.Context) ([]model.RemoteAlbum, error) {
+ albums := make([]model.RemoteAlbum, 0)
albumBytes, err := c.GetAllValues(ctx, model.RemoteAlbums)
if err != nil {
return nil, err
}
for _, albumJson := range albumBytes {
- album := model.Album{}
+ album := model.RemoteAlbum{}
err = json.Unmarshal(albumJson, &album)
if err != nil {
return nil, err
diff --git a/pkg/download.go b/pkg/download.go
index c747eae801..4e82ecdeb6 100644
--- a/pkg/download.go
+++ b/pkg/download.go
@@ -29,14 +29,14 @@ func (c *ClICtrl) initiateDownload(ctx context.Context) error {
return nil
}
-func (c *ClICtrl) getRemoteFiles(ctx context.Context) ([]model.PhotoFile, error) {
- files := make([]model.PhotoFile, 0)
+func (c *ClICtrl) getRemoteFiles(ctx context.Context) ([]model.RemoteFile, error) {
+ files := make([]model.RemoteFile, 0)
fileBytes, err := c.GetAllValues(ctx, model.RemoteFiles)
if err != nil {
return nil, err
}
for _, fileJson := range fileBytes {
- file := model.PhotoFile{}
+ file := model.RemoteFile{}
err = json.Unmarshal(fileJson, &file)
if err != nil {
return nil, err
diff --git a/pkg/log/debug_print.go b/pkg/log/debug_print.go
index d161e5c520..3cdc120976 100644
--- a/pkg/log/debug_print.go
+++ b/pkg/log/debug_print.go
@@ -7,7 +7,7 @@ import (
// This file contains functions that are used to print debug information to the console.
-func PrintAlbum(a *model.Album) {
+func PrintAlbum(a *model.RemoteAlbum) {
fmt.Printf("=======\n")
fmt.Printf("ID: %d\n", a.ID)
fmt.Printf("OwnerID: %d\n", a.OwnerID)
diff --git a/pkg/mappers.go b/pkg/mappers.go
index 531fa96854..2aa67ee9e9 100644
--- a/pkg/mappers.go
+++ b/pkg/mappers.go
@@ -11,8 +11,8 @@ import (
"log"
)
-func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Collection) (*model.Album, error) {
- var album model.Album
+func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Collection) (*model.RemoteAlbum, error) {
+ var album model.RemoteAlbum
userID := ctx.Value("user_id").(int64)
album.OwnerID = collection.Owner.ID
album.ID = collection.ID
@@ -69,7 +69,7 @@ func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Colle
return &album, nil
}
-func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.Album, file api.File) (*model.PhotoFile, error) {
+func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.RemoteAlbum, file api.File) (*model.RemoteFile, error) {
if file.IsDeleted {
return nil, errors.New("file is deleted")
}
@@ -81,14 +81,14 @@ func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.Album,
if err != nil {
return nil, err
}
- var photoFile model.PhotoFile
+ var photoFile model.RemoteFile
photoFile.ID = file.ID
photoFile.Key = *model.MakeEncString(fileKey, c.CliKey)
photoFile.FileNonce = file.File.DecryptionHeader
photoFile.ThumbnailNonce = file.Thumbnail.DecryptionHeader
photoFile.OwnerID = file.OwnerID
if file.Info != nil {
- photoFile.Info = model.PhotoInfo{
+ photoFile.Info = model.Info{
FileSize: file.Info.FileSize,
ThumbnailSize: file.Info.ThumbnailSize,
}
diff --git a/pkg/model/album.go b/pkg/model/album.go
deleted file mode 100644
index 203fe14495..0000000000
--- a/pkg/model/album.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package model
-
-type 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 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.go
deleted file mode 100644
index 04234b7cf1..0000000000
--- a/pkg/model/photo_file.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package model
-
-type PhotoFile struct {
- ID int64 `json:"id"`
- OwnerID int64 `json:"ownerID"`
- Key EncString `json:"key"`
- LastUpdateTime int64 `json:"lastUpdateTime"`
- FileNonce string `json:"fileNonce"`
- ThumbnailNonce string `json:"thumbnailNonce"`
- Metadata map[string]interface{} `json:"metadata"`
- PrivateMetadata map[string]interface{} `json:"privateMetadata"`
- PublicMetadata map[string]interface{} `json:"publicMetadata"`
- Info PhotoInfo `json:"info"`
-}
-
-type PhotoInfo struct {
- FileSize int64 `json:"fileSize,omitempty"`
- ThumbnailSize int64 `json:"thumbSize,omitempty"`
-}
diff --git a/pkg/model/remote.go b/pkg/model/remote.go
new file mode 100644
index 0000000000..812fe5475f
--- /dev/null
+++ b/pkg/model/remote.go
@@ -0,0 +1,32 @@
+package model
+
+type RemoteFile struct {
+ ID int64 `json:"id"`
+ OwnerID int64 `json:"ownerID"`
+ Key EncString `json:"key"`
+ LastUpdateTime int64 `json:"lastUpdateTime"`
+ FileNonce string `json:"fileNonce"`
+ ThumbnailNonce string `json:"thumbnailNonce"`
+ Metadata map[string]interface{} `json:"metadata"`
+ PrivateMetadata map[string]interface{} `json:"privateMetadata"`
+ PublicMetadata map[string]interface{} `json:"publicMetadata"`
+ Info Info `json:"info"`
+}
+
+type Info struct {
+ FileSize int64 `json:"fileSize,omitempty"`
+ ThumbnailSize int64 `json:"thumbSize,omitempty"`
+}
+
+type RemoteAlbum 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 map[string]interface{} `json:"publicMeta"`
+ PrivateMeta map[string]interface{} `json:"privateMeta"`
+ SharedMeta map[string]interface{} `json:"sharedMeta"`
+ LastUpdatedAt int64 `json:"lastUpdatedAt"`
+}