From 7d9df9cc4733460044601bfaa93bb3058e6ebb38 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sun, 5 Jan 2025 11:41:42 +0900 Subject: [PATCH] improved: add `mode=imported` for startup snapshot `/customnode/installed` - current snapshot `/customnode/installed?mode=imported` - startup snapshot --- glob/manager_core.py | 18 ++++++++++++++++++ glob/manager_server.py | 19 +++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/glob/manager_core.py b/glob/manager_core.py index 7de81d69..dfc6a9e8 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -1396,6 +1396,24 @@ def identify_node_pack_from_path(fullpath): return module_name, commit_hash, '' +def get_installed_node_packs(): + res = {} + + for x in get_custom_nodes_paths(): + for y in os.listdir(x): + if y == '__pycache__' or y.endswith('.disabled'): + continue + + fullpath = os.path.join(x, y) + info = identify_node_pack_from_path(fullpath) + if info is None: + continue + + res[info[0]] = [info[1], info[2]] + + return res + + def get_channel_dict(): global channel_dict diff --git a/glob/manager_server.py b/glob/manager_server.py index 6f59163a..45c6afab 100644 --- a/glob/manager_server.py +++ b/glob/manager_server.py @@ -537,21 +537,16 @@ def populate_markdown(x): x['title'] = manager_util.sanitize_tag(x['title']) +# freeze imported version +startup_time_installed_node_packs = core.get_installed_node_packs() @routes.get("/customnode/installed") async def installed_list(request): - res = {} + mode = request.query.get('mode', 'default') - for x in core.get_custom_nodes_paths(): - for y in os.listdir(x): - if y == '__pycache__' or y.endswith('.disabled'): - continue - - fullpath = os.path.join(x, y) - info = core.identify_node_pack_from_path(fullpath) - if info is None: - continue - - res[info[0]] = [info[1], info[2]] + if mode == 'imported': + res = startup_time_installed_node_packs + else: + res = core.get_installed_node_packs() return web.json_response(res, content_type='application/json')