improved: add mode=imported for startup snapshot

`/customnode/installed` - current snapshot
`/customnode/installed?mode=imported` - startup snapshot
This commit is contained in:
Dr.Lt.Data 2025-01-05 11:41:42 +09:00
parent 0f73a69d7d
commit 7d9df9cc47
2 changed files with 25 additions and 12 deletions

View File

@ -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

View File

@ -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')