Remove unused IPC method

This commit is contained in:
Manav Rathi 2024-04-14 20:11:25 +05:30
parent 87077417a2
commit 18ac361688
No known key found for this signature in database
4 changed files with 7 additions and 28 deletions

View file

@ -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);

View file

@ -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());

View file

@ -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

View file

@ -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