Move mappers inside separate pkg
This commit is contained in:
parent
93925b0731
commit
342325a56a
|
@ -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")
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue