From 415aa19d91d55608cbf8b7e3b7371913956abbdd Mon Sep 17 00:00:00 2001 From: Allen Ding Date: Thu, 25 Jul 2024 19:05:33 -0700 Subject: [PATCH] fix rmdir error if splash dir was previously unset --- src/main/ipc.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/ipc.ts b/src/main/ipc.ts index fc0f23a..b135fce 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -8,7 +8,7 @@ if (process.platform === "linux") import("./venmic"); import { execFile } from "child_process"; import { app, BrowserWindow, clipboard, dialog, nativeImage, RelaunchOptions, session, shell } from "electron"; -import { mkdirSync, readFileSync, watch } from "fs"; +import { mkdirSync, readFileSync, watch, existsSync } from "fs"; import { open, readFile, copyFile, mkdir, rmdir } from "fs/promises"; import { release } from "os"; import { randomBytes } from "crypto"; @@ -141,7 +141,9 @@ handle(IpcEvents.SELECT_IMAGE_PATH, async () => { const imageName = "splash_" + uuid + extname(originalPath); const destPath = join(VESKTOP_SPLASH_DIR, imageName); - await rmdir(VESKTOP_SPLASH_DIR, {recursive: true}) + if (existsSync(VESKTOP_SPLASH_DIR)) { + await rmdir(VESKTOP_SPLASH_DIR, {recursive: true}); + } await mkdir(VESKTOP_SPLASH_DIR, {recursive: true}); await copyFile(originalPath, destPath);