From: Codebuddy Date: Sat, 15 Aug 2026 09:35:42 +0000 (+0800) Subject: fix: 上传/更新 skill 时按 zip 内声明名覆盖已存在技能,避免产生重复目录 X-Git-Url: http://acesimba.cloud/gitweb/?a=commitdiff_plain;h=a1b30c29feb40a3a4c563bbee7fc09dcc5b52288;p=codebuddy-web.git fix: 上传/更新 skill 时按 zip 内声明名覆盖已存在技能,避免产生重复目录 - _do_upload_skill 在解析出技能名后,若 zip 内 frontmatter name 对应一个已存在的技能目录, 则安装到该目录(覆盖)而非新建,修复“更新后列表出现两个同名技能”的问题 --- diff --git a/backend/app.py b/backend/app.py index 2dc80ad..97671ec 100644 --- a/backend/app.py +++ b/backend/app.py @@ -957,6 +957,13 @@ def _do_upload_skill(body: dict): else: fallback = (body.get("filename") or "skill").rsplit(".", 1)[0] name = fallback + # 防重复:若 zip 内声明的 skill 名对应一个已存在的技能目录,则覆盖该目录, + # 而不是新建一个(避免“更新/上传”后列表出现两个同名技能)。 + zf_fm = _skill_name_from_zip(zf) + if zf_fm: + existing = SKILLS_ROOT / zf_fm + if existing.exists() and existing.resolve() != (SKILLS_ROOT / name).resolve(): + name = zf_fm if not _NAME_RE.match(name): zf.close() return JSONResponse({"error": f"skill 名称非法: {name}(仅允许字母数字 - _,长度 1-64)"}, status_code=400)