From 041a81cfd430beebbce42538f6962127818ec2cd Mon Sep 17 00:00:00 2001 From: xmk23333 Date: Sun, 14 Dec 2025 22:15:38 +0800 Subject: [PATCH] fix: add file existence checks before backup and fix CSS typo --- src/main/resolve/backup.ts | 36 ++++++++++++++----- .../src/components/settings/webdav-config.tsx | 2 +- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/main/resolve/backup.ts b/src/main/resolve/backup.ts index fa28c4c..0c68d63 100644 --- a/src/main/resolve/backup.ts +++ b/src/main/resolve/backup.ts @@ -59,15 +59,33 @@ export async function webdavBackup(): Promise { const { client, webdavDir, webdavMaxBackups } = await getWebDAVClient() const zip = new AdmZip() - zip.addLocalFile(appConfigPath()) - zip.addLocalFile(controledMihomoConfigPath()) - zip.addLocalFile(profileConfigPath()) - zip.addLocalFile(overrideConfigPath()) - zip.addLocalFolder(themesDir(), 'themes') - zip.addLocalFolder(profilesDir(), 'profiles') - zip.addLocalFolder(overrideDir(), 'override') - zip.addLocalFolder(rulesDir(), 'rules') - zip.addLocalFolder(subStoreDir(), 'substore') + if (existsSync(appConfigPath())) { + zip.addLocalFile(appConfigPath()) + } + if (existsSync(controledMihomoConfigPath())) { + zip.addLocalFile(controledMihomoConfigPath()) + } + if (existsSync(profileConfigPath())) { + zip.addLocalFile(profileConfigPath()) + } + if (existsSync(overrideConfigPath())) { + zip.addLocalFile(overrideConfigPath()) + } + if (existsSync(themesDir())) { + zip.addLocalFolder(themesDir(), 'themes') + } + if (existsSync(profilesDir())) { + zip.addLocalFolder(profilesDir(), 'profiles') + } + if (existsSync(overrideDir())) { + zip.addLocalFolder(overrideDir(), 'override') + } + if (existsSync(rulesDir())) { + zip.addLocalFolder(rulesDir(), 'rules') + } + if (existsSync(subStoreDir())) { + zip.addLocalFolder(subStoreDir(), 'substore') + } const date = new Date() const zipFileName = `${process.platform}_${dayjs(date).format('YYYY-MM-DD_HH-mm-ss')}.zip` diff --git a/src/renderer/src/components/settings/webdav-config.tsx b/src/renderer/src/components/settings/webdav-config.tsx index 5d63f1e..068d2b8 100644 --- a/src/renderer/src/components/settings/webdav-config.tsx +++ b/src/renderer/src/components/settings/webdav-config.tsx @@ -200,7 +200,7 @@ const WebdavConfig: React.FC = () => { /> -
+