mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-09 22:24:23 +08:00
feat: endpoint customnode/installed is added
This commit is contained in:
parent
95ee037a44
commit
9b5adfeb2c
@ -308,6 +308,25 @@ class ManagedResult:
|
||||
return self
|
||||
|
||||
|
||||
def get_commit_hash(fullpath):
|
||||
git_head = os.path.join(fullpath, '.git', 'HEAD')
|
||||
if os.path.exists(git_head):
|
||||
with open(git_head) as f:
|
||||
line = f.readline()
|
||||
|
||||
if line.startswith("ref: "):
|
||||
ref = os.path.join(fullpath, '.git', line[5:].strip())
|
||||
if os.path.exists(ref):
|
||||
with open(ref) as f2:
|
||||
return f2.readline().strip()
|
||||
else:
|
||||
return "unknown"
|
||||
else:
|
||||
return line
|
||||
|
||||
return "unknown"
|
||||
|
||||
|
||||
class UnifiedManager:
|
||||
def __init__(self):
|
||||
self.cnr_inactive_nodes = {} # node_id -> node_version -> fullpath
|
||||
|
||||
@ -542,6 +542,33 @@ def populate_markdown(x):
|
||||
x['title'] = manager_util.sanitize_tag(x['title'])
|
||||
|
||||
|
||||
@routes.get("/customnode/installed")
|
||||
async def installed_list(request):
|
||||
result = {}
|
||||
for x in folder_paths.get_folder_paths('custom_nodes'):
|
||||
for y in os.listdir(x):
|
||||
if y.endswith('.disabled') or y == '__pycache__' or y.endswith('.py') or y.endswith('.example'):
|
||||
continue
|
||||
|
||||
spec = y.split('@')
|
||||
|
||||
if len(spec) == 2:
|
||||
ver = spec[1].replace('_', '.')
|
||||
|
||||
if ver == 'nightly':
|
||||
ver = None
|
||||
else:
|
||||
ver = None
|
||||
|
||||
# extract commit hash
|
||||
if ver is None:
|
||||
ver = core.get_commit_hash(os.path.join(x, y))
|
||||
|
||||
result[y] = ver
|
||||
|
||||
return web.json_response(result, content_type='application/json')
|
||||
|
||||
|
||||
@routes.get("/customnode/getlist")
|
||||
async def fetch_customnode_list(request):
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user