diff --git a/desktop/src/main/fs.ts b/desktop/src/main/fs.ts index 94652d93d..d8cfe7714 100644 --- a/desktop/src/main/fs.ts +++ b/desktop/src/main/fs.ts @@ -20,7 +20,7 @@ export const fsRm = (path: string) => fs.rm(path); export const fsReadTextFile = async (filePath: string) => fs.readFile(filePath, "utf-8"); -export const fsWriteTextFile = (path: string, contents: string) => +export const fsWriteFile = (path: string, contents: string) => fs.writeFile(path, contents); /** diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.ts index 17984c1cf..2a7480302 100644 --- a/desktop/src/main/ipc.ts +++ b/desktop/src/main/ipc.ts @@ -24,7 +24,7 @@ import { fsRename, fsRm, fsRmdir, - fsWriteTextFile, + fsWriteFile, isFolder, saveStreamToDisk, } from "./fs"; @@ -129,8 +129,8 @@ export const attachIPCHandlers = () => { ipcMain.handle("fsReadTextFile", (_, path: string) => fsReadTextFile(path)); - ipcMain.handle("fsWriteTextFile", (_, path: string, contents: string) => - fsWriteTextFile(path, contents), + ipcMain.handle("fsWriteFile", (_, path: string, contents: string) => + fsWriteFile(path, contents), ); // - Conversion diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts index 057ca9ebb..c709468cb 100644 --- a/desktop/src/preload.ts +++ b/desktop/src/preload.ts @@ -115,8 +115,8 @@ const fsRm = (path: string): Promise => ipcRenderer.invoke("fsRm", path); const fsReadTextFile = (path: string): Promise => ipcRenderer.invoke("fsReadTextFile", path); -const fsWriteTextFile = (path: string, contents: string): Promise => - ipcRenderer.invoke("fsWriteTextFile", path, contents); +const fsWriteFile = (path: string, contents: string): Promise => + ipcRenderer.invoke("fsWriteFile", path, contents); // - AUDIT below this @@ -326,7 +326,7 @@ contextBridge.exposeInMainWorld("electron", { rmdir: fsRmdir, rm: fsRm, readTextFile: fsReadTextFile, - writeTextFile: fsWriteTextFile, + writeFile: fsWriteFile, }, // - Conversion diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.ts index 996b911de..165947f04 100644 --- a/web/apps/photos/src/services/export/index.ts +++ b/web/apps/photos/src/services/export/index.ts @@ -884,7 +884,7 @@ class ExportService { try { const exportRecord = await this.getExportRecord(folder); const newRecord: ExportRecord = { ...exportRecord, ...newData }; - await ensureElectron().fs.writeTextFile( + await ensureElectron().fs.writeFile( `${folder}/${exportRecordFileName}`, JSON.stringify(newRecord, null, 2), ); @@ -1076,7 +1076,7 @@ class ExportService { fileExportName: string, file: EnteFile, ) { - await ensureElectron().fs.writeTextFile( + await ensureElectron().fs.writeFile( getFileMetadataExportPath(collectionExportPath, fileExportName), getGoogleLikeMetadataFile(fileExportName, file), ); @@ -1105,7 +1105,7 @@ class ExportService { private createEmptyExportRecord = async (exportRecordJSONPath: string) => { const exportRecord: ExportRecord = NULL_EXPORT_RECORD; - await ensureElectron().fs.writeTextFile( + await ensureElectron().fs.writeFile( exportRecordJSONPath, JSON.stringify(exportRecord, null, 2), ); diff --git a/web/packages/next/types/ipc.ts b/web/packages/next/types/ipc.ts index 70e21a10c..60bbb39f8 100644 --- a/web/packages/next/types/ipc.ts +++ b/web/packages/next/types/ipc.ts @@ -189,16 +189,16 @@ export interface Electron { */ rm: (path: string) => Promise; + /** Read the string contents of a file at {@link path}. */ + readTextFile: (path: string) => Promise; + /** * Write a string to a file, replacing the file if it already exists. * * @param path The path of the file. * @param contents The string contents to write. */ - writeTextFile: (path: string, contents: string) => Promise; - - /** Read the string contents of a file at {@link path}. */ - readTextFile: (path: string) => Promise; + writeFile: (path: string, contents: string) => Promise; }; /*