feat: 채널 이름 변경 시 워크스페이스+폴더 자동 연동
- on_guild_channel_update 이벤트로 이름 변경 감지 - workspace.rename_workspace(): 이름+폴더 변경 (VW_Proj 하위에만) - 변경 완료 시 채널에 알림 Embed 전송
This commit is contained in:
@@ -251,6 +251,39 @@ class WorkspaceManager:
|
||||
return True
|
||||
return False
|
||||
|
||||
def rename_workspace(self, channel_id: int, new_name: str) -> tuple[bool, str]:
|
||||
"""워크스페이스 이름 + 폴더 변경.
|
||||
|
||||
Returns: (성공 여부, 새 경로 또는 에러 메시지)
|
||||
"""
|
||||
ws = self.workspaces.get(channel_id)
|
||||
if not ws:
|
||||
return False, "워크스페이스 없음"
|
||||
|
||||
old_name = ws.name
|
||||
old_path = Path(ws.path)
|
||||
|
||||
# 이름만 변경 (폴더는 기본경로일 때만 이동)
|
||||
ws.name = new_name
|
||||
|
||||
# 기본경로(VW_Proj 아래)인 경우 폴더도 이동
|
||||
base_dir = Path(config.WORKSPACE_BASE_DIR)
|
||||
if old_path.parent == base_dir and old_path.exists():
|
||||
new_path = base_dir / new_name
|
||||
if not new_path.exists():
|
||||
try:
|
||||
old_path.rename(new_path)
|
||||
ws.path = str(new_path)
|
||||
logger.info(f"폴더 이동: {old_path} -> {new_path}")
|
||||
except OSError as e:
|
||||
logger.warning(f"폴더 이동 실패: {e}")
|
||||
ws.path = str(old_path) # 폴더는 유지
|
||||
|
||||
self._save()
|
||||
logger.info(f"워크스페이스 이름 변경: {old_name} -> {new_name}")
|
||||
return True, ws.path
|
||||
|
||||
def list_all(self) -> list[Workspace]:
|
||||
"""전체 워크스페이스 목록."""
|
||||
return list(self.workspaces.values())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user