Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move mappers inside separate pkg

Neeraj Gupta342325a56aa1
diff --git a/pkg/mappers.go b/pkg/mapper/photo.go
similarity index 92%
rename from pkg/mappers.go
rename to pkg/mapper/photo.go
index 9ac99f3b3e..63617c5adf 100644
--- a/pkg/mappers.go
+++ b/pkg/mapper/photo.go
@@ -1,4 +1,4 @@
-package pkg
+package mapper
import (
"cli-go/internal/api"
@@ -12,7 +12,7 @@ import (
"log"
)
-func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Collection, holder *secrets.KeyHolder) (*model.RemoteAlbum, error) {
+func MapCollectionToAlbum(ctx context.Context, collection api.Collection, holder *secrets.KeyHolder) (*model.RemoteAlbum, error) {
var album model.RemoteAlbum
userID := ctx.Value("user_id").(int64)
album.OwnerID = collection.Owner.ID
@@ -70,7 +70,7 @@ func (c *ClICtrl) mapCollectionToAlbum(ctx context.Context, collection api.Colle
return &album, nil
}
-func (c *ClICtrl) mapApiFileToPhotoFile(ctx context.Context, album model.RemoteAlbum, file api.File, holder *secrets.KeyHolder) (*model.RemoteFile, error) {
+func MapApiFileToPhotoFile(ctx context.Context, album model.RemoteAlbum, file api.File, holder *secrets.KeyHolder) (*model.RemoteFile, error) {
if file.IsDeleted {
return nil, errors.New("file is deleted")
}
diff --git a/pkg/remote_sync.go b/pkg/remote_sync.go
index fa0dc6828d..78db914508 100644
--- a/pkg/remote_sync.go
+++ b/pkg/remote_sync.go
@@ -1,6 +1,7 @@
package pkg
import (
+ "cli-go/pkg/mapper"
"cli-go/pkg/model"
"cli-go/utils/encoding"
"context"
@@ -25,7 +26,7 @@ func (c *ClICtrl) fetchRemoteCollections(ctx context.Context) error {
if lastSyncTime == 0 && collection.IsDeleted {
continue
}
- album, mapErr := c.mapCollectionToAlbum(ctx, collection, c.KeyHolder)
+ album, mapErr := mapper.MapCollectionToAlbum(ctx, collection, c.KeyHolder)
if mapErr != nil {
return mapErr
}
@@ -84,7 +85,7 @@ func (c *ClICtrl) fetchRemoteFiles(ctx context.Context) error {
// on first sync, no need to sync delete markers
continue
}
- photoFile, err := c.mapApiFileToPhotoFile(ctx, album, file, c.KeyHolder)
+ photoFile, err := mapper.MapApiFileToPhotoFile(ctx, album, file, c.KeyHolder)
if err != nil {
return err
}