π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Final touches
Manav Rathi5edca461f76d
diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.tsindex a838003d06..ad93dcb5a9 100644--- a/web/apps/photos/src/utils/file/index.ts+++ b/web/apps/photos/src/utils/file/index.ts@@ -1,6 +1,6 @@-import ElectronAPIs from "@/next/electron";import { convertBytesToHumanReadable } from "@/next/file";import log from "@/next/log";+import type { Electron } from "@/next/types/ipc";import { workerBridge } from "@/next/worker/worker-bridge";import ComlinkCryptoWorker from "@ente/shared/crypto";import { CustomError } from "@ente/shared/error";@@ -689,8 +689,10 @@ export async function downloadFilesWithProgress(canceller,});- if (isElectron()) {+ const electron = globalThis.electron;+ if (electron) {await downloadFilesDesktop(+ electron,files,{ increaseSuccess, increaseFailed, isCancelled },downloadDirPath,@@ -712,8 +714,9 @@ export async function downloadSelectedFiles(return;}let downloadDirPath: string;- if (isElectron()) {- downloadDirPath = await ElectronAPIs.selectDirectory();+ const electron = globalThis.electron;+ if (electron) {+ downloadDirPath = await electron.selectDirectory();if (!downloadDirPath) {return;}@@ -730,8 +733,9 @@ export async function downloadSingleFile(setFilesDownloadProgressAttributes: SetFilesDownloadProgressAttributes,) {let downloadDirPath: string;- if (isElectron()) {- downloadDirPath = await ElectronAPIs.selectDirectory();+ const electron = globalThis.electron;+ if (electron) {+ downloadDirPath = await electron.selectDirectory();if (!downloadDirPath) {return;}@@ -765,7 +769,8 @@ export async function downloadFiles(}}-export async function downloadFilesDesktop(+async function downloadFilesDesktop(+ electron: Electron,files: EnteFile[],progressBarUpdater: {increaseSuccess: () => void;@@ -780,7 +785,7 @@ export async function downloadFilesDesktop(if (progressBarUpdater?.isCancelled()) {return;}- await downloadFileDesktop(fileReader, file, downloadPath);+ await downloadFileDesktop(electron, fileReader, file, downloadPath);progressBarUpdater?.increaseSuccess();} catch (e) {log.error("download fail for file", e);@@ -789,7 +794,8 @@ export async function downloadFilesDesktop(}}-export async function downloadFileDesktop(+async function downloadFileDesktop(+ electron: Electron,fileReader: FileReader,file: EnteFile,downloadPath: string,@@ -811,7 +817,7 @@ export async function downloadFileDesktop(livePhoto.imageNameTitle,);const imageStream = generateStreamFromArrayBuffer(livePhoto.image);- await ElectronAPIs.saveStreamToDisk(+ await electron.saveStreamToDisk(getFileExportPath(downloadPath, imageExportName),imageStream,);@@ -821,12 +827,12 @@ export async function downloadFileDesktop(livePhoto.videoNameTitle,);const videoStream = generateStreamFromArrayBuffer(livePhoto.video);- await ElectronAPIs.saveStreamToDisk(+ await electron.saveStreamToDisk(getFileExportPath(downloadPath, videoExportName),videoStream,);} catch (e) {- await ElectronAPIs.deleteFile(+ await electron.deleteFile(getFileExportPath(downloadPath, imageExportName),);throw e;@@ -836,7 +842,7 @@ export async function downloadFileDesktop(downloadPath,file.metadata.title,);- await ElectronAPIs.saveStreamToDisk(+ await electron.saveStreamToDisk(getFileExportPath(downloadPath, fileExportName),updatedFileStream,);diff --git a/web/packages/next/electron.ts b/web/packages/next/electron.tsindex de9611fec6..d7af86c47b 100644--- a/web/packages/next/electron.ts+++ b/web/packages/next/electron.ts@@ -1,26 +1,5 @@import type { Electron } from "./types/ipc";-// type ElectronAPIsType =-// TODO (MR):-// eslint-disable-next-line @typescript-eslint/no-explicit-any-const ElectronAPIs = (globalThis as unknown as any)[- // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-member-access- "ElectronAPIs"-] as Electron;--// /**-// * Extend the global object's (`globalThis`) interface to state that it can-// * potentially hold a property called `electron`. It will be injected by our-// * preload.js script when we're running in the context of our desktop app.-// */-// declare global {-// const electron: Electron | undefined;-// }--// export const globalElectron = globalThis.electron;--export default ElectronAPIs;-/*** A wrapper over a non-null assertion of `globalThis.electron`.*