From f53664321597f85a9d8c09ffd993c40aff1c5c5b Mon Sep 17 00:00:00 2001 From: an-lee Date: Tue, 2 Apr 2024 14:49:48 +0800 Subject: [PATCH] empty cache dir before quit (#478) --- enjoy/src/main.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/enjoy/src/main.ts b/enjoy/src/main.ts index d9d7c6b3..f7135d40 100644 --- a/enjoy/src/main.ts +++ b/enjoy/src/main.ts @@ -1,5 +1,6 @@ import { app, BrowserWindow, protocol, net } from "electron"; import path from "path"; +import fs from "fs-extra"; import settings from "@main/settings"; import "@main/i18n"; import mainWindow from "@main/window"; @@ -88,5 +89,9 @@ app.on("activate", () => { } }); -// In this file you can include the rest of your app's specific main process -// code. You can also put them in separate files and import them here. +// Clean up cache folder before quit +app.on("before-quit", () => { + try { + fs.emptyDirSync(settings.cachePath()); + } catch (err) {} +});