π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove unnecessary checks
Manav Rathieb64a00ed247
diff --git a/desktop/src/main/fs.ts b/desktop/src/main/fs.tsindex cdf51aff01..749f21bf25 100644--- a/desktop/src/main/fs.ts+++ b/desktop/src/main/fs.ts@@ -16,6 +16,8 @@ export const fsMkdirIfNeeded = (dirPath: string) =>export const fsRmdir = (path: string) => fs.rmdir(path);+export const fsRm = (path: string) => fs.rm(path);+/*** Write a (web) ReadableStream to a file at the given {@link filePath}.*@@ -107,15 +109,3 @@ export const isFolder = async (dirPath: string) => {const stats = await fs.stat(dirPath);return stats.isDirectory();};--export const deleteFile = async (filePath: string) => {- // Ensure it exists- if (!existsSync(filePath)) return;-- // And is a file- const stat = await fs.stat(filePath);- if (!stat.isFile()) throw new Error("Path is not a file");-- // rm it- return fs.rm(filePath);-};diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.tsindex ae80475952..12bcc72bf4 100644--- a/desktop/src/main/ipc.ts+++ b/desktop/src/main/ipc.ts@@ -18,7 +18,7 @@ import {showUploadZipDialog,} from "./dialogs";import {- deleteFile,+ fsRm,fsRmdir,fsExists,fsMkdirIfNeeded,@@ -175,6 +175,10 @@ export const attachIPCHandlers = () => {ipcMain.handle("fsMkdirIfNeeded", (_, dirPath) => fsMkdirIfNeeded(dirPath));+ ipcMain.handle("fsRmdir", (_, path: string) => fsRmdir(path));++ ipcMain.handle("fsRm", (_, path: string) => fsRm(path));+// - FS LegacyipcMain.handle(@@ -195,10 +199,6 @@ export const attachIPCHandlers = () => {moveFile(oldPath, newPath),);- ipcMain.handle("fsRmdir", (_, path: string) => fsRmdir(path));-- ipcMain.handle("deleteFile", (_, path: string) => deleteFile(path));-// - UploadipcMain.handle("getPendingUploads", () => getPendingUploads());diff --git a/desktop/src/preload.ts b/desktop/src/preload.tsindex 9c91612602..d33e2b6751 100644--- a/desktop/src/preload.ts+++ b/desktop/src/preload.ts@@ -244,8 +244,7 @@ const moveFile = (oldPath: string, newPath: string): Promise<void> =>const fsRmdir = (path: string): Promise<void> =>ipcRenderer.invoke("fsRmdir", path);-const deleteFile = (path: string): Promise<void> =>- ipcRenderer.invoke("deleteFile", path);+const fsRm = (path: string): Promise<void> => ipcRenderer.invoke("fsRm", path);// - Upload@@ -351,6 +350,7 @@ contextBridge.exposeInMainWorld("electron", {rename: fsRename,mkdirIfNeeded: fsMkdirIfNeeded,rmdir: fsRmdir,+ rm: fsRm,},// - FS legacy@@ -360,7 +360,6 @@ contextBridge.exposeInMainWorld("electron", {readTextFile,isFolder,moveFile,- deleteFile,// - Uploaddiff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.tsindex adf4e8313f..0c5fb23efc 100644--- a/web/apps/photos/src/services/export/index.ts+++ b/web/apps/photos/src/services/export/index.ts@@ -1147,7 +1147,7 @@ class ExportService {videoStream,);} catch (e) {- await electron.deleteFile(+ await electron.fs.rm(`${collectionExportPath}/${imageExportName}`,);throw e;diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.tsindex 2a3b156f2f..8f72cb4508 100644--- a/web/apps/photos/src/utils/file/index.ts+++ b/web/apps/photos/src/utils/file/index.ts@@ -834,7 +834,7 @@ async function downloadFileDesktop(videoStream,);} catch (e) {- await electron.deleteFile(`${downloadPath}/${imageExportName}`);+ await electron.fs.rm(`${downloadPath}/${imageExportName}`);throw e;}} else {diff --git a/web/packages/next/types/ipc.ts b/web/packages/next/types/ipc.tsindex 62a992f49e..301a951917 100644--- a/web/packages/next/types/ipc.ts+++ b/web/packages/next/types/ipc.ts@@ -181,6 +181,13 @@ export interface Electron {* Delete the directory at the {@link path} if it is empty.*/rmdir: (path: string) => Promise<void>;++ /**+ * Equivalent of `rm`.+ *+ * Delete the file at {@link path}.+ */+ rm: (path: string) => Promise<void>;};/*@@ -301,7 +308,6 @@ export interface Electron {readTextFile: (path: string) => Promise<string>;isFolder: (dirPath: string) => Promise<boolean>;moveFile: (oldPath: string, newPath: string) => Promise<void>;- deleteFile: (path: string) => Promise<void>;// - Upload