fix AutoBackup

This commit is contained in:
jxxghp
2024-06-28 09:26:52 +08:00
parent f6758f1777
commit bf0f680e81
2 changed files with 10 additions and 5 deletions

View File

@@ -259,11 +259,12 @@
"name": "自动备份", "name": "自动备份",
"description": "自动备份数据和配置文件。", "description": "自动备份数据和配置文件。",
"labels": "系统设置", "labels": "系统设置",
"version": "1.2", "version": "1.3",
"icon": "Time_machine_B.png", "icon": "Time_machine_B.png",
"author": "thsrite", "author": "thsrite",
"level": 1, "level": 1,
"history": { "history": {
"v1.3":"去除已废弃的环境变量引用",
"v1.2": "增强API安全性" "v1.2": "增强API安全性"
} }
}, },

View File

@@ -25,7 +25,7 @@ class AutoBackup(_PluginBase):
# 插件图标 # 插件图标
plugin_icon = "Time_machine_B.png" plugin_icon = "Time_machine_B.png"
# 插件版本 # 插件版本
plugin_version = "1.2" plugin_version = "1.3"
# 插件作者 # 插件作者
plugin_author = "thsrite" plugin_author = "thsrite"
# 作者主页 # 作者主页
@@ -153,10 +153,14 @@ class AutoBackup(_PluginBase):
backup_file = f"bk_{time.strftime('%Y%m%d%H%M%S')}" backup_file = f"bk_{time.strftime('%Y%m%d%H%M%S')}"
backup_path = bk_path / backup_file backup_path = bk_path / backup_file
backup_path.mkdir(parents=True) backup_path.mkdir(parents=True)
# 把现有的相关文件进行copy备份 # 把现有的相关文件进行copy备份
if settings.LIBRARY_CATEGORY: category_file = config_path / "category.yaml"
shutil.copy(f'{config_path}/category.yaml', backup_path) if category_file.exists():
shutil.copy(f'{config_path}/user.db', backup_path) 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' zip_file = str(backup_path) + '.zip'
if os.path.exists(zip_file): if os.path.exists(zip_file):