π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Download: return path to decrypted file
Neeraj Gupta78bec602623d
diff --git a/pkg/download.go b/pkg/download.goindex 785e0d76e5..863f578584 100644--- a/pkg/download.go+++ b/pkg/download.go@@ -1,28 +1,34 @@package pkgimport (+ "cli-go/internal/crypto"+ "cli-go/pkg/model"+ "cli-go/utils/encoding""context""fmt"+ "log""os")-func (c *ClICtrl) initiateDownload(ctx context.Context) error {- files, err := c.getRemoteFiles(ctx)+func (c *ClICtrl) downloadAndDecrypt(+ ctx context.Context,+ file model.RemoteFile,+ deviceKey []byte,+) (*string, error) {+ dir, err := os.MkdirTemp("", "ente-cli-download/*")if err != nil {- return err+ return nil, err}- dir, err := os.MkdirTemp("", "photos-download")+ downloadPath := fmt.Sprintf("%s/%d", dir, file.ID)+ log.Printf("Downloading file %d to %s", file.ID, downloadPath)+ err = c.Client.DownloadFile(ctx, file.ID, downloadPath)if err != nil {- return err+ return nil, err}- fmt.Println("total files to download: in diroector", len(files), dir)- //for _, file := range files {- // //downloadPath := fmt.Sprintf("%s/%d", dir, file.ID)- // //log.Printf("Downloading file %d to %s", file.ID, downloadPath)- // //err = c.Client.DownloadFile(ctx, file.ID, downloadPath)- // //if err != nil {- // // return err- // //}- //}- return nil+ decryptedPath := fmt.Sprintf("%s/%d.decrypted", dir, file.ID)+ err = crypto.DecryptFile(downloadPath, decryptedPath, file.Key.MustDecrypt(deviceKey), encoding.DecodeBase64(file.FileNonce))+ if err != nil {+ return nil, err+ }+ return &decryptedPath, nil}