mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-10 06:34:24 +08:00
conservative migration system
keep original repo name as possible if unknown node
This commit is contained in:
parent
10055f578b
commit
ea3413be9b
@ -874,7 +874,9 @@ class UnifiedManager:
|
|||||||
if repo_and_path is None:
|
if repo_and_path is None:
|
||||||
return result.fail(f'Specified inactive node not exists: {node_id}@unknown')
|
return result.fail(f'Specified inactive node not exists: {node_id}@unknown')
|
||||||
from_path = repo_and_path[1]
|
from_path = repo_and_path[1]
|
||||||
to_path = os.path.join(custom_nodes_path, f"{node_id}@unknown")
|
# NOTE: Keep original name as possible if unknown node
|
||||||
|
# to_path = os.path.join(custom_nodes_path, f"{node_id}@unknown")
|
||||||
|
to_path = os.path.join(custom_nodes_path, node_id)
|
||||||
elif version_spec == 'nightly':
|
elif version_spec == 'nightly':
|
||||||
self.unified_disable(node_id, False)
|
self.unified_disable(node_id, False)
|
||||||
from_path = self.nightly_inactive_nodes.get(node_id)
|
from_path = self.nightly_inactive_nodes.get(node_id)
|
||||||
@ -932,10 +934,12 @@ class UnifiedManager:
|
|||||||
|
|
||||||
if is_unknown:
|
if is_unknown:
|
||||||
repo_and_path = self.unknown_active_nodes.get(node_id)
|
repo_and_path = self.unknown_active_nodes.get(node_id)
|
||||||
to_path = os.path.join(custom_nodes_path, '.disabled', f"{node_id}@unknown")
|
# NOTE: Keep original name as possible if unknown node
|
||||||
|
# to_path = os.path.join(custom_nodes_path, '.disabled', f"{node_id}@unknown")
|
||||||
|
to_path = os.path.join(custom_nodes_path, '.disabled', node_id)
|
||||||
|
|
||||||
if repo_and_path is None or not os.path.exists(repo_and_path[1]):
|
if repo_and_path is None or not os.path.exists(repo_and_path[1]):
|
||||||
return result.fail(f'Specified active node not exists: {node_id}@unknown')
|
return result.fail(f'Specified active node not exists: {node_id}')
|
||||||
|
|
||||||
shutil.move(repo_and_path[1], to_path)
|
shutil.move(repo_and_path[1], to_path)
|
||||||
result.append((repo_and_path[1], to_path))
|
result.append((repo_and_path[1], to_path))
|
||||||
@ -1275,33 +1279,34 @@ class UnifiedManager:
|
|||||||
|
|
||||||
self.nightly_inactive_nodes.update(fixes)
|
self.nightly_inactive_nodes.update(fixes)
|
||||||
|
|
||||||
print(f"Migration: STAGE 2")
|
# NOTE: Don't migration unknown node - keep original name as possible
|
||||||
# migrate unknown inactive
|
# print(f"Migration: STAGE 2")
|
||||||
fixes = {}
|
# # migrate unknown inactive
|
||||||
for x, v in self.unknown_inactive_nodes.items():
|
# fixes = {}
|
||||||
if v[1].endswith('@unknown'):
|
# for x, v in self.unknown_inactive_nodes.items():
|
||||||
continue
|
# if v[1].endswith('@unknown'):
|
||||||
|
# continue
|
||||||
|
#
|
||||||
|
# new_path = os.path.join(custom_nodes_path, '.disabled', f"{x}@unknown")
|
||||||
|
# shutil.move(v[1], new_path)
|
||||||
|
# fixes[x] = v[0], new_path
|
||||||
|
#
|
||||||
|
# self.unknown_inactive_nodes.update(fixes)
|
||||||
|
|
||||||
new_path = os.path.join(custom_nodes_path, '.disabled', f"{x}@unknown")
|
# print(f"Migration: STAGE 3")
|
||||||
shutil.move(v[1], new_path)
|
|
||||||
fixes[x] = v[0], new_path
|
|
||||||
|
|
||||||
self.unknown_inactive_nodes.update(fixes)
|
|
||||||
|
|
||||||
print(f"Migration: STAGE 3")
|
|
||||||
# migrate unknown active nodes
|
# migrate unknown active nodes
|
||||||
fixes = {}
|
# fixes = {}
|
||||||
for x, v in self.unknown_active_nodes.items():
|
# for x, v in self.unknown_active_nodes.items():
|
||||||
if v[1].endswith('@unknown'):
|
# if v[1].endswith('@unknown'):
|
||||||
continue
|
# continue
|
||||||
|
#
|
||||||
|
# new_path = os.path.join(custom_nodes_path, f"{x}@unknown")
|
||||||
|
# shutil.move(v[1], new_path)
|
||||||
|
# fixes[x] = v[0], new_path
|
||||||
|
#
|
||||||
|
# self.unknown_active_nodes.update(fixes)
|
||||||
|
|
||||||
new_path = os.path.join(custom_nodes_path, f"{x}@unknown")
|
print(f"Migration: STAGE 2")
|
||||||
shutil.move(v[1], new_path)
|
|
||||||
fixes[x] = v[0], new_path
|
|
||||||
|
|
||||||
self.unknown_active_nodes.update(fixes)
|
|
||||||
|
|
||||||
print(f"Migration: STAGE 4")
|
|
||||||
# migrate active nodes
|
# migrate active nodes
|
||||||
fixes = {}
|
fixes = {}
|
||||||
for x, v in self.active_nodes.items():
|
for x, v in self.active_nodes.items():
|
||||||
@ -1759,7 +1764,11 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
|
|||||||
return await unified_manager.install_by_id(cnr_id, version_spec='nightly')
|
return await unified_manager.install_by_id(cnr_id, version_spec='nightly')
|
||||||
else:
|
else:
|
||||||
repo_name = os.path.splitext(os.path.basename(url))[0]
|
repo_name = os.path.splitext(os.path.basename(url))[0]
|
||||||
node_dir = f"{repo_name}@unknown"
|
|
||||||
|
# NOTE: Keep original name as possible if unknown node
|
||||||
|
# node_dir = f"{repo_name}@unknown"
|
||||||
|
node_dir = repo_name
|
||||||
|
|
||||||
repo_path = os.path.join(custom_nodes_path, node_dir)
|
repo_path = os.path.join(custom_nodes_path, node_dir)
|
||||||
disabled_repo_path1 = os.path.join(custom_nodes_path, '.disabled', node_dir)
|
disabled_repo_path1 = os.path.join(custom_nodes_path, '.disabled', node_dir)
|
||||||
disabled_repo_path2 = os.path.join(custom_nodes_path, repo_name+'.disabled') # old style
|
disabled_repo_path2 = os.path.join(custom_nodes_path, repo_name+'.disabled') # old style
|
||||||
@ -2636,33 +2645,26 @@ async def restore_snapshot(snapshot_path, git_helper_extras=None):
|
|||||||
# check need to migrate
|
# check need to migrate
|
||||||
need_to_migrate = False
|
need_to_migrate = False
|
||||||
|
|
||||||
|
|
||||||
async def check_need_to_migrate():
|
async def check_need_to_migrate():
|
||||||
global need_to_migrate
|
global need_to_migrate
|
||||||
|
|
||||||
|
await unified_manager.reload('cache')
|
||||||
|
await unified_manager.load_nightly(channel='default', mode='cache')
|
||||||
|
|
||||||
legacy_custom_nodes = []
|
legacy_custom_nodes = []
|
||||||
|
|
||||||
try:
|
for x in unified_manager.active_nodes.values():
|
||||||
import folder_paths
|
if x[0] == 'nightly' and not x[1].endswith('@nightly'):
|
||||||
except:
|
legacy_custom_nodes.append(x[1])
|
||||||
try:
|
|
||||||
sys.path.append(comfy_path)
|
|
||||||
import folder_paths
|
|
||||||
except:
|
|
||||||
raise Exception(f"Invalid COMFYUI_PATH: {comfy_path}")
|
|
||||||
|
|
||||||
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
for x in unified_manager.nightly_inactive_nodes.values():
|
||||||
for x in node_paths:
|
if not x.endswith('@nightly'):
|
||||||
subdirs = [d for d in os.listdir(x) if os.path.isdir(os.path.join(x, d))]
|
legacy_custom_nodes.append(x)
|
||||||
for subdir in subdirs:
|
|
||||||
if subdir in ['.disabled', '__pycache__']:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if '@' not in subdir:
|
|
||||||
need_to_migrate = True
|
|
||||||
legacy_custom_nodes.append(subdir)
|
|
||||||
|
|
||||||
if len(legacy_custom_nodes) > 0:
|
if len(legacy_custom_nodes) > 0:
|
||||||
print("\n--------------------- ComfyUI-Manager migration notice --------------------")
|
print("\n--------------------- ComfyUI-Manager migration notice --------------------")
|
||||||
print("The following custom nodes were installed using the old management method and require migration:")
|
print("The following custom nodes were installed using the old management method and require migration:")
|
||||||
print(", ".join(legacy_custom_nodes))
|
print(", ".join(legacy_custom_nodes))
|
||||||
print("---------------------------------------------------------------------------\n")
|
print("---------------------------------------------------------------------------\n")
|
||||||
|
need_to_migrate = True
|
||||||
|
|||||||
@ -1722,7 +1722,8 @@ async def default_cache_update():
|
|||||||
d = get_cache("alter-list.json")
|
d = get_cache("alter-list.json")
|
||||||
e = get_cache("github-stats.json")
|
e = get_cache("github-stats.json")
|
||||||
|
|
||||||
await asyncio.gather(a, b, c, d, e, core.check_need_to_migrate())
|
await asyncio.gather(a, b, c, d, e)
|
||||||
|
await core.check_need_to_migrate()
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(target=lambda: asyncio.run(default_cache_update())).start()
|
threading.Thread(target=lambda: asyncio.run(default_cache_update())).start()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user