Compare commits
2 Commits
5f1808f108
...
6ecb0d70e3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ecb0d70e3 | ||
|
|
6b9ae7f86a |
@ -786,9 +786,14 @@ async def remove_skill(
|
||||
|
||||
# 使用线程池删除目录(避免阻塞事件循环)
|
||||
await asyncio.to_thread(shutil.rmtree, skill_dir_real)
|
||||
|
||||
logger.info(f"Successfully removed skill directory: {skill_dir_real}")
|
||||
|
||||
# 同步删除 robot 目录下的 skill 副本
|
||||
robot_skill_dir = os.path.join(base_dir, "projects", "robot", bot_id, "skills", skill_name)
|
||||
if os.path.exists(robot_skill_dir):
|
||||
await asyncio.to_thread(shutil.rmtree, robot_skill_dir)
|
||||
logger.info(f"Also removed robot skill directory: {robot_skill_dir}")
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"message": f"Skill '{skill_name}' 删除成功",
|
||||
|
||||
@ -392,16 +392,17 @@ def _extract_skills_to_robot(bot_id: str, skills: List[str], project_path: Path)
|
||||
Path("skills"),
|
||||
]
|
||||
skills_target_dir = project_path / "robot" / bot_id / "skills"
|
||||
|
||||
# 先清空 skills_target_dir,然后重新复制
|
||||
if skills_target_dir.exists():
|
||||
logger.info(f" Removing existing skills directory: {skills_target_dir}")
|
||||
shutil.rmtree(skills_target_dir)
|
||||
|
||||
skills_target_dir.mkdir(parents=True, exist_ok=True)
|
||||
logger.info(f"Copying skills to {skills_target_dir}")
|
||||
|
||||
for skill in skills:
|
||||
target_dir = skills_target_dir / os.path.basename(skill)
|
||||
|
||||
# 如果目标目录已存在,跳过复制
|
||||
if target_dir.exists():
|
||||
logger.info(f" Skill '{skill}' already exists in {target_dir}, skipping")
|
||||
continue
|
||||
|
||||
source_dir = None
|
||||
|
||||
# 简单名称:按优先级顺序在多个目录中查找
|
||||
@ -416,10 +417,6 @@ def _extract_skills_to_robot(bot_id: str, skills: List[str], project_path: Path)
|
||||
logger.warning(f" Skill directory '{skill}' not found in any source directory: {[str(d) for d in skills_source_dirs]}")
|
||||
continue
|
||||
|
||||
if not source_dir.exists():
|
||||
logger.warning(f" Skill directory not found: {source_dir}")
|
||||
continue
|
||||
|
||||
target_dir = skills_target_dir / os.path.basename(skill)
|
||||
|
||||
try:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user