π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move checkExistsAndCreateDir out of preload
Manav Rathi81ba5379c9c3
diff --git a/desktop/src/main/fs.ts b/desktop/src/main/fs.tsindex 50a9ddc61a..12527d551f 100644--- a/desktop/src/main/fs.ts+++ b/desktop/src/main/fs.ts@@ -2,5 +2,11 @@* @file file system related functions exposed over the context bridge.*/import { existsSync } from "node:fs";+import * as fs from "node:fs/promises";export const fsExists = (path: string) => existsSync(path);++/* TODO: Audit below this */++export const checkExistsAndCreateDir = (dirPath: string) =>+ fs.mkdir(dirPath, { recursive: true });diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.tsindex 83726fc8d0..aa3841d2de 100644--- a/desktop/src/main/ipc.ts+++ b/desktop/src/main/ipc.ts@@ -8,11 +8,9 @@import { ipcMain } from "electron/main";import { appVersion } from "../services/appUpdater";+import { checkExistsAndCreateDir, fsExists } from "./fs";import { openDirectory, openLogDirectory } from "./general";import { logToDisk } from "./log";-import { fsExists } from "./fs";--// - Generalexport const attachIPCHandlers = () => {// Notes:@@ -40,7 +38,11 @@ export const attachIPCHandlers = () => {ipcMain.handle("openLogDirectory", (_) => openLogDirectory());// See: [Note: Catching exception during .send/.on]- ipcMain.on("logToDisk", (_, msg) => logToDisk(msg));+ ipcMain.on("logToDisk", (_, message) => logToDisk(message));ipcMain.handle("fsExists", (_, path) => fsExists(path));++ ipcMain.handle("checkExistsAndCreateDir", (_, dirPath) =>+ checkExistsAndCreateDir(dirPath),+ );};diff --git a/desktop/src/preload.ts b/desktop/src/preload.tsindex b81a7a35ea..dad8b95c77 100644--- a/desktop/src/preload.ts+++ b/desktop/src/preload.ts@@ -95,6 +95,11 @@ const logToDisk = (message: string): void =>const fsExists = (path: string): Promise<boolean> =>ipcRenderer.invoke("fsExists", path);+// - AUDIT below this++const checkExistsAndCreateDir = (dirPath: string): Promise<void> =>+ ipcRenderer.invoke("checkExistsAndCreateDir", dirPath);+// - FIXME below this/* preload: duplicated logError */@@ -168,9 +173,6 @@ const writeNodeStream = async (// - Export-const checkExistsAndCreateDir = (dirPath: string) =>- fs.mkdir(dirPath, { recursive: true });-const saveStreamToDisk = writeStream;const saveFileToDisk = (path: string, contents: string) =>@@ -439,8 +441,11 @@ contextBridge.exposeInMainWorld("ElectronAPIs", {exists: fsExists,},- // - Export+ // - FS legacy+ // TODO: Move these into fs + document + rename if neededcheckExistsAndCreateDir,++ // - ExportsaveStreamToDisk,saveFileToDisk,diff --git a/web/packages/shared/electron/types.ts b/web/packages/shared/electron/types.tsindex 3cb519d7a7..81a16d5937 100644--- a/web/packages/shared/electron/types.ts+++ b/web/packages/shared/electron/types.ts@@ -80,6 +80,8 @@ export interface ElectronAPIsType {/** TODO: AUDIT below this */checkExistsAndCreateDir: (dirPath: string) => Promise<void>;++ /** TODO: FIXME or migrate below this */saveStreamToDisk: (path: string,fileStream: ReadableStream<any>,