From bf0f680e81d0ff06443cda1ebdb77c8ced472ee0 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 28 Jun 2024 09:26:52 +0800 Subject: [PATCH] fix AutoBackup --- package.json | 3 ++- plugins/autobackup/__init__.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 45f6a46..365f612 100644 --- a/package.json +++ b/package.json @@ -259,11 +259,12 @@ "name": "自动备份", "description": "自动备份数据和配置文件。", "labels": "系统设置", - "version": "1.2", + "version": "1.3", "icon": "Time_machine_B.png", "author": "thsrite", "level": 1, "history": { + "v1.3":"去除已废弃的环境变量引用", "v1.2": "增强API安全性" } }, diff --git a/plugins/autobackup/__init__.py b/plugins/autobackup/__init__.py index fa0299e..72c4a77 100644 --- a/plugins/autobackup/__init__.py +++ b/plugins/autobackup/__init__.py @@ -25,7 +25,7 @@ class AutoBackup(_PluginBase): # 插件图标 plugin_icon = "Time_machine_B.png" # 插件版本 - plugin_version = "1.2" + plugin_version = "1.3" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -153,10 +153,14 @@ class AutoBackup(_PluginBase): backup_file = f"bk_{time.strftime('%Y%m%d%H%M%S')}" backup_path = bk_path / backup_file backup_path.mkdir(parents=True) + # 把现有的相关文件进行copy备份 - if settings.LIBRARY_CATEGORY: - shutil.copy(f'{config_path}/category.yaml', backup_path) - shutil.copy(f'{config_path}/user.db', backup_path) + category_file = config_path / "category.yaml" + if category_file.exists(): + shutil.copy(category_file, backup_path) + userdb_file = config_path / "user.db" + if userdb_file.exists(): + shutil.copy(userdb_file, backup_path) zip_file = str(backup_path) + '.zip' if os.path.exists(zip_file):