@ -27,7 +27,7 @@ except:
print ( f " [WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version. " )
print ( f " [WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version. " )
version = [ 1 , 23 , 1 ]
version = [ 1 , 24 ]
version_str = f " V { version [ 0 ] } . { version [ 1 ] } " + ( f ' . { version [ 2 ] } ' if len ( version ) > 2 else ' ' )
version_str = f " V { version [ 0 ] } . { version [ 1 ] } " + ( f ' . { version [ 2 ] } ' if len ( version ) > 2 else ' ' )
print ( f " ### Loading: ComfyUI-Manager ( { version_str } ) " )
print ( f " ### Loading: ComfyUI-Manager ( { version_str } ) " )
@ -349,7 +349,7 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
process = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = subprocess . PIPE )
process = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = subprocess . PIPE )
output , _ = process . communicate ( )
output , _ = process . communicate ( )
output = output . decode ( ' utf-8 ' ) . strip ( )
output = output . decode ( ' utf-8 ' ) . strip ( )
except Exception as e :
except Exception :
print ( f ' [ComfyUI-Manager] failed to fixing ' )
print ( f ' [ComfyUI-Manager] failed to fixing ' )
if ' detected dubious ' in output :
if ' detected dubious ' in output :
@ -359,28 +359,29 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
f ' ----------------------------------------------------------------------------------------- \n ' )
f ' ----------------------------------------------------------------------------------------- \n ' )
if do_update :
if do_update :
if " CUSTOM NODE PULL: True " in output :
if " CUSTOM NODE PULL: Success " in output :
process . wait ( )
process . wait ( )
print ( f " \r Updated: { path } " )
print ( f " \r Updated: { path } " )
return True
return True , True # updated
elif " CUSTOM NODE PULL: None " in output :
elif " CUSTOM NODE PULL: None " in output :
process . wait ( )
process . wait ( )
return True
return False , True # there is no updat e
else :
else :
print ( f " \r Update error: { path } " )
print ( f " \r Update error: { path } " )
process . wait ( )
process . wait ( )
return False
return False , False # update failed
else :
else :
if " CUSTOM NODE CHECK: True " in output :
if " CUSTOM NODE CHECK: True " in output :
process . wait ( )
process . wait ( )
return True
return True , True
elif " CUSTOM NODE CHECK: False " in output :
elif " CUSTOM NODE CHECK: False " in output :
process . wait ( )
process . wait ( )
return False
return False , True
else :
else :
print ( f " \r Fetch error: { path } " )
print ( f " \r Fetch error: { path } " )
print ( f " \n { output } \n " )
process . wait ( )
process . wait ( )
return False
return False , True
def __win_check_git_pull ( path ) :
def __win_check_git_pull ( path ) :
@ -408,9 +409,10 @@ def git_repo_has_updates(path, do_fetch=False, do_update=False):
raise ValueError ( ' Not a git repository ' )
raise ValueError ( ' Not a git repository ' )
if platform . system ( ) == " Windows " :
if platform . system ( ) == " Windows " :
res = __win_check_git_update ( path , do_fetch , do_update )
updated , success = __win_check_git_update ( path , do_fetch , do_update )
if updated and success :
execute_install_script ( None , path , lazy_mode = True )
execute_install_script ( None , path , lazy_mode = True )
return re s
return updated , succes s
else :
else :
# Fetch the latest commits from the remote repository
# Fetch the latest commits from the remote repository
repo = git . Repo ( path )
repo = git . Repo ( path )
@ -428,6 +430,14 @@ def git_repo_has_updates(path, do_fetch=False, do_update=False):
if repo . head . is_detached :
if repo . head . is_detached :
switch_to_default_branch ( repo )
switch_to_default_branch ( repo )
current_branch = repo . active_branch
branch_name = current_branch . name
remote_commit_hash = repo . refs [ f ' { remote_name } / { branch_name } ' ] . object . hexsha
if commit_hash == remote_commit_hash :
repo . close ( )
return False , True
try :
try :
remote . pull ( )
remote . pull ( )
repo . git . submodule ( ' update ' , ' --init ' , ' --recursive ' )
repo . git . submodule ( ' update ' , ' --init ' , ' --recursive ' )
@ -436,15 +446,17 @@ def git_repo_has_updates(path, do_fetch=False, do_update=False):
if commit_hash != new_commit_hash :
if commit_hash != new_commit_hash :
execute_install_script ( None , path )
execute_install_script ( None , path )
print ( f " \x1b [2K \r Updated: { path } " )
print ( f " \x1b [2K \r Updated: { path } " )
return True
return True , True
else :
else :
return False
return False , False
except Exception as e :
except Exception as e :
print ( f " \n Updating failed: { path } \n { e } " , file = sys . stderr )
print ( f " \n Updating failed: { path } \n { e } " , file = sys . stderr )
return False , False
if repo . head . is_detached :
if repo . head . is_detached :
return True
repo . close ( )
return True , True
# Get commit hash of the remote branch
# Get commit hash of the remote branch
current_branch = repo . active_branch
current_branch = repo . active_branch
@ -460,9 +472,12 @@ def git_repo_has_updates(path, do_fetch=False, do_update=False):
# Compare the commit dates to determine if the local repository is behind the remote repository
# Compare the commit dates to determine if the local repository is behind the remote repository
if commit_date < remote_commit_date :
if commit_date < remote_commit_date :
return True
repo . close ( )
return True , True
return False
repo . close ( )
return False , True
def git_pull ( path ) :
def git_pull ( path ) :
@ -658,14 +673,17 @@ def check_a_custom_node_installed(item, do_fetch=False, do_update_check=True, do
dir_path = os . path . join ( custom_nodes_path , dir_name )
dir_path = os . path . join ( custom_nodes_path , dir_name )
if os . path . exists ( dir_path ) :
if os . path . exists ( dir_path ) :
try :
try :
if do_update_check and git_repo_has_updates ( dir_path , do_fetch , do_update ) :
update_state , success = git_repo_has_updates ( dir_path , do_fetch , do_update )
if ( do_update_check or do_update ) and update_state :
item [ ' installed ' ] = ' Update '
item [ ' installed ' ] = ' Update '
elif sys . __comfyui_manager_is_import_failed_extension ( dir_name ) :
elif do_update and not success :
item [ ' installed ' ] = ' Fail '
elif cm_global . try_call ( api = " cm.is_import_failed_extension " , name = dir_name ) :
item [ ' installed ' ] = ' Fail '
item [ ' installed ' ] = ' Fail '
else :
else :
item [ ' installed ' ] = ' True '
item [ ' installed ' ] = ' True '
except :
except :
if sys . __comfyui_manager_is_import_failed_extension ( dir_name ) :
if cm_global . try_call ( api = " cm.is_import_failed_extension " , name = dir_name ) :
item [ ' installed ' ] = ' Fail '
item [ ' installed ' ] = ' Fail '
else :
else :
item [ ' installed ' ] = ' True '
item [ ' installed ' ] = ' True '
@ -688,7 +706,7 @@ def check_a_custom_node_installed(item, do_fetch=False, do_update_check=True, do
file_path = os . path . join ( base_path , dir_name )
file_path = os . path . join ( base_path , dir_name )
if os . path . exists ( file_path ) :
if os . path . exists ( file_path ) :
if sys . __comfyui_manager_is_import_failed_extension ( dir_name ) :
if cm_global . try_call ( api = " cm.is_import_failed_extension " , name = dir_name ) :
item [ ' installed ' ] = ' Fail '
item [ ' installed ' ] = ' Fail '
else :
else :
item [ ' installed ' ] = ' True '
item [ ' installed ' ] = ' True '
@ -774,12 +792,17 @@ async def update_all(request):
check_custom_nodes_installed ( json_obj , do_update = True )
check_custom_nodes_installed ( json_obj , do_update = True )
update_exists = any ( item [ ' installed ' ] == ' Update ' for item in json_obj [ ' custom_nodes ' ] )
updated = [ item [ ' title ' ] for item in json_obj [ ' custom_nodes ' ] if item [ ' installed ' ] == ' Update ' ]
failed = [ item [ ' title ' ] for item in json_obj [ ' custom_nodes ' ] if item [ ' installed ' ] == ' Fail ' ]
if update_exists :
res = { ' updated ' : updated , ' failed ' : failed }
return web . Response ( status = 201 )
return web . Response ( status = 200 )
if len ( updated ) == 0 and len ( failed ) == 0 :
status = 200
else :
status = 201
return web . json_response ( res , status = status , content_type = ' application/json ' )
except :
except :
return web . Response ( status = 400 )
return web . Response ( status = 400 )