Parcourir la source

Remove unused IPC method

Manav Rathi il y a 1 an
Parent
commit
18ac361688
4 fichiers modifiés avec 7 ajouts et 28 suppressions
  1. 0 11
      desktop/src/main/fs.ts
  2. 2 7
      desktop/src/main/ipc.ts
  3. 5 9
      desktop/src/preload.ts
  4. 0 1
      web/packages/next/types/ipc.ts

+ 0 - 11
desktop/src/main/fs.ts

@@ -3,7 +3,6 @@
  */
 import { createWriteStream, existsSync } from "node:fs";
 import fs from "node:fs/promises";
-import path from "node:path";
 import { Readable } from "node:stream";
 
 export const fsExists = (path: string) => existsSync(path);
@@ -91,16 +90,6 @@ export const saveFileToDisk = (path: string, contents: string) =>
 export const readTextFile = async (filePath: string) =>
     fs.readFile(filePath, "utf-8");
 
-export const moveFile = async (sourcePath: string, destinationPath: string) => {
-    if (existsSync(destinationPath)) {
-        throw new Error("Destination file already exists");
-    }
-    // check if destination folder exists
-    const destinationFolder = path.dirname(destinationPath);
-    await fs.mkdir(destinationFolder, { recursive: true });
-    await fs.rename(sourcePath, destinationPath);
-};
-
 export const isFolder = async (dirPath: string) => {
     if (!existsSync(dirPath)) return false;
     const stats = await fs.stat(dirPath);

+ 2 - 7
desktop/src/main/ipc.ts

@@ -18,13 +18,12 @@ import {
     showUploadZipDialog,
 } from "./dialogs";
 import {
-    fsRm,
-    fsRmdir,
     fsExists,
     fsMkdirIfNeeded,
     fsRename,
+    fsRm,
+    fsRmdir,
     isFolder,
-    moveFile,
     readTextFile,
     saveFileToDisk,
     saveStreamToDisk,
@@ -195,10 +194,6 @@ export const attachIPCHandlers = () => {
 
     ipcMain.handle("isFolder", (_, dirPath: string) => isFolder(dirPath));
 
-    ipcMain.handle("moveFile", (_, oldPath: string, newPath: string) =>
-        moveFile(oldPath, newPath),
-    );
-
     // - Upload
 
     ipcMain.handle("getPendingUploads", () => getPendingUploads());

+ 5 - 9
desktop/src/preload.ts

@@ -105,6 +105,11 @@ const fsMkdirIfNeeded = (dirPath: string): Promise<void> =>
 const fsRename = (oldPath: string, newPath: string): Promise<void> =>
     ipcRenderer.invoke("fsRename", oldPath, newPath);
 
+const fsRmdir = (path: string): Promise<void> =>
+    ipcRenderer.invoke("fsRmdir", path);
+
+const fsRm = (path: string): Promise<void> => ipcRenderer.invoke("fsRm", path);
+
 // - AUDIT below this
 
 // - Conversion
@@ -238,14 +243,6 @@ const readTextFile = (path: string): Promise<string> =>
 const isFolder = (dirPath: string): Promise<boolean> =>
     ipcRenderer.invoke("isFolder", dirPath);
 
-const moveFile = (oldPath: string, newPath: string): Promise<void> =>
-    ipcRenderer.invoke("moveFile", oldPath, newPath);
-
-const fsRmdir = (path: string): Promise<void> =>
-    ipcRenderer.invoke("fsRmdir", path);
-
-const fsRm = (path: string): Promise<void> => ipcRenderer.invoke("fsRm", path);
-
 // - Upload
 
 const getPendingUploads = (): Promise<{
@@ -359,7 +356,6 @@ contextBridge.exposeInMainWorld("electron", {
     saveFileToDisk,
     readTextFile,
     isFolder,
-    moveFile,
 
     // - Upload
 

+ 0 - 1
web/packages/next/types/ipc.ts

@@ -307,7 +307,6 @@ export interface Electron {
     saveFileToDisk: (path: string, contents: string) => Promise<void>;
     readTextFile: (path: string) => Promise<string>;
     isFolder: (dirPath: string) => Promise<boolean>;
-    moveFile: (oldPath: string, newPath: string) => Promise<void>;
 
     // - Upload