Skip to content

Commit 4087b96

Browse files
committed
fix(cli): handle URL-based node specs in reinstall_node()
resolve_node_spec() returns the full URL as node_name, but unknown_active_nodes is keyed by repo basename. This caused unified_uninstall/purge_node_state to miss the node, leaving the directory in place. The subsequent install then fails with "Already exists". Fix: detect URL input first, extract repo basename for uninstall/purge, then pass the original URL to install_node.
1 parent 099aed1 commit 4087b96

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

cm_cli/__main__.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,29 @@ def install_node(node_spec_str, is_all=False, cnt_msg='', **kwargs):
238238

239239

240240
def reinstall_node(node_spec_str, is_all=False, cnt_msg=''):
241-
node_spec = unified_manager.resolve_node_spec(node_spec_str)
241+
if core.is_valid_url(node_spec_str):
242+
# URL-based: resolve_node_spec returns the full URL as node_name,
243+
# but unknown_active_nodes is keyed by repo basename.
244+
import shutil
245+
url = node_spec_str.rstrip('/')
246+
repo_name = os.path.splitext(os.path.basename(url))[0]
247+
repo_path = os.path.join(core.get_default_custom_nodes_path(), repo_name)
242248

243-
node_name, version_spec, _ = node_spec
249+
unified_manager.unified_uninstall(repo_name, True)
250+
unified_manager.purge_node_state(repo_name)
251+
252+
if os.path.exists(repo_path):
253+
shutil.rmtree(repo_path)
244254

245-
# Best-effort uninstall via normal path
246-
unified_manager.unified_uninstall(node_name, version_spec == 'unknown')
255+
install_node(node_spec_str, is_all=is_all, cnt_msg=cnt_msg, raise_on_fail=True)
256+
else:
257+
node_spec = unified_manager.resolve_node_spec(node_spec_str)
258+
node_name, version_spec, _ = node_spec
247259

248-
# Fallback: purge all state and directories regardless of categorization
249-
# Handles categorization mismatch between cm_cli invocations (e.g. unknown→nightly)
250-
unified_manager.purge_node_state(node_name)
260+
unified_manager.unified_uninstall(node_name, version_spec == 'unknown')
261+
unified_manager.purge_node_state(node_name)
251262

252-
install_node(node_name, is_all=is_all, cnt_msg=cnt_msg, raise_on_fail=True)
263+
install_node(node_name, is_all=is_all, cnt_msg=cnt_msg, raise_on_fail=True)
253264

254265

255266
def fix_node(node_spec_str, is_all=False, cnt_msg=''):

0 commit comments

Comments
 (0)