fix(update): preserve host plugin entrypoint during Docker upgrades

This commit is contained in:
jxxghp
2026-09-16 12:24:19 +08:00
parent 11eea66d27
commit d5e469a4e4
5 changed files with 113 additions and 22 deletions

View File

@@ -323,19 +323,22 @@ function stage_runtime_payload() {
[ -f "${stage_app}/uv.lock" ] || return 1
[ -f "${TMP_PATH}/dist/index.html" ] || return 1
if [ -e "${stage_plugin_dir}" ] && [ ! -d "${stage_plugin_dir}" ]; then
ERROR "插件运行目录不是目录"
return 1
fi
mkdir -p "${stage_plugin_dir}" || return 1
# 新版后端归档提供宿主兼容入口;仅迁移旧目录中的插件内容,避免旧版入口覆盖它。
if ! find "${stage_plugin_dir}" -mindepth 1 -maxdepth 1 \
! -name "__init__.py" -exec rm -rf -- {} \;; then
return 1
fi
if [ -d "${APP_DIR}/app/plugins" ]; then
rm -rf "${stage_plugin_dir}" || return 1
mkdir -p "${stage_plugin_dir}" || return 1
if ! cp -a "${APP_DIR}/app/plugins/." "${stage_plugin_dir}/"; then
if ! find "${APP_DIR}/app/plugins" -mindepth 1 -maxdepth 1 \
! -name "__init__.py" -exec cp -a {} "${stage_plugin_dir}/" \;; then
return 1
fi
else
mkdir -p "${stage_plugin_dir}" || return 1
fi
# 保留 app.plugins 兼容入口;V1/V2 插件仍从这里导入 _PluginBase。
# 删除后 app.plugins 会退化为 namespace package,旧插件会在启动时全部导入失败。
# 该文件必须是不含实现的包说明:契约基类归 app.sdk.plugin,包根自带旧版实现会
# 遮蔽兼容符号,此时 Compat 会直接拒绝导入并报出覆盖了哪个 canonical 路径。
if [ ! -f "${stage_plugin_dir}/__init__.py" ]; then
ERROR "插件运行目录缺少 app.plugins 兼容入口"
return 1