aa38fe776a
* feat: 添加数据迁移功能 * test: 添加迁移相关测试 * feat: 备份插件及相关持久化目录 * fix: 修复版本号比较逻辑,添加相关测试 * fix: 清洗文件名,添加相关测试 * fix: 修复安全文件名测试用例断言 * refactor: 优化代码,为备份模块提取公用常量 * feat: 修改备份版本校验逻辑,允许强制小版本间导入 * fix: 修复备份创建时间读取,修复备份相关i18n * refactor(backup): 使用 astrbot_path 统一管理备份目录路径 * fix(backup): 清理备份模块中未使用的导入 * refactor(backup): 统一备份路径与参数并移除未用附件目录 - 通过 astrbot_path 动态获取备份/知识库/数据相关路径 - 移除 exporter/importer 未使用的 attachments_dir/data_root 传参 - 更新备份路由与测试用例的构造参数 * fix(dashboard): alias mermaid to dist entry for Vite prebundle * fix(backup): 放行start-time接口到白名单以处理备份导入后jwt token变化导致无法自动刷新webui的问题 * chore(backup): 统一配置路径以使用动态数据目录 * refactor(backup): 使用 VersionComparator 替代重复的版本比较函数 * style(backup test): format code --------- Co-authored-by: Soulter <905617992@qq.com>
74 lines
2.5 KiB
Python
74 lines
2.5 KiB
Python
"""Astrbot统一路径获取
|
|
|
|
项目路径:固定为源码所在路径
|
|
根目录路径:默认为当前工作目录,可通过环境变量 ASTRBOT_ROOT 指定
|
|
数据目录路径:固定为根目录下的 data 目录
|
|
配置文件路径:固定为数据目录下的 config 目录
|
|
插件目录路径:固定为数据目录下的 plugins 目录
|
|
插件数据目录路径:固定为数据目录下的 plugin_data 目录
|
|
T2I 模板目录路径:固定为数据目录下的 t2i_templates 目录
|
|
WebChat 数据目录路径:固定为数据目录下的 webchat 目录
|
|
临时文件目录路径:固定为数据目录下的 temp 目录
|
|
"""
|
|
|
|
import os
|
|
|
|
|
|
def get_astrbot_path() -> str:
|
|
"""获取Astrbot项目路径"""
|
|
return os.path.realpath(
|
|
os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../"),
|
|
)
|
|
|
|
|
|
def get_astrbot_root() -> str:
|
|
"""获取Astrbot根目录路径"""
|
|
if path := os.environ.get("ASTRBOT_ROOT"):
|
|
return os.path.realpath(path)
|
|
return os.path.realpath(os.getcwd())
|
|
|
|
|
|
def get_astrbot_data_path() -> str:
|
|
"""获取Astrbot数据目录路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_root(), "data"))
|
|
|
|
|
|
def get_astrbot_config_path() -> str:
|
|
"""获取Astrbot配置文件路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_data_path(), "config"))
|
|
|
|
|
|
def get_astrbot_plugin_path() -> str:
|
|
"""获取Astrbot插件目录路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_data_path(), "plugins"))
|
|
|
|
|
|
def get_astrbot_plugin_data_path() -> str:
|
|
"""获取Astrbot插件数据目录路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_data_path(), "plugin_data"))
|
|
|
|
|
|
def get_astrbot_t2i_templates_path() -> str:
|
|
"""获取Astrbot T2I 模板目录路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_data_path(), "t2i_templates"))
|
|
|
|
|
|
def get_astrbot_webchat_path() -> str:
|
|
"""获取Astrbot WebChat 数据目录路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_data_path(), "webchat"))
|
|
|
|
|
|
def get_astrbot_temp_path() -> str:
|
|
"""获取Astrbot临时文件目录路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_data_path(), "temp"))
|
|
|
|
|
|
def get_astrbot_knowledge_base_path() -> str:
|
|
"""获取Astrbot知识库根目录路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_data_path(), "knowledge_base"))
|
|
|
|
|
|
def get_astrbot_backups_path() -> str:
|
|
"""获取Astrbot备份目录路径"""
|
|
return os.path.realpath(os.path.join(get_astrbot_data_path(), "backups"))
|