update model dB
support .zip file model
This commit is contained in:
@@ -15,6 +15,7 @@ import threading
|
||||
import json
|
||||
import time
|
||||
import yaml
|
||||
import zipfile
|
||||
|
||||
glob_path = os.path.join(os.path.dirname(__file__)) # ComfyUI-Manager/glob
|
||||
sys.path.append(glob_path)
|
||||
@@ -22,7 +23,7 @@ sys.path.append(glob_path)
|
||||
import cm_global
|
||||
from manager_util import *
|
||||
|
||||
version = [2, 29]
|
||||
version = [2, 30]
|
||||
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
||||
|
||||
comfyui_manager_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
@@ -1156,3 +1157,30 @@ async def extract_nodes_from_workflow(filepath, mode='local', channel_url='defau
|
||||
|
||||
return used_exts, unknown_nodes
|
||||
|
||||
|
||||
def unzip(model_path):
|
||||
if not os.path.exists(model_path):
|
||||
print(f"[ComfyUI-Manager] unzip: File not found: {model_path}")
|
||||
return False
|
||||
|
||||
base_dir = os.path.dirname(model_path)
|
||||
filename = os.path.basename(model_path)
|
||||
target_dir = os.path.join(base_dir, filename[:-4])
|
||||
|
||||
os.makedirs(target_dir, exist_ok=True)
|
||||
|
||||
with zipfile.ZipFile(model_path, 'r') as zip_ref:
|
||||
zip_ref.extractall(target_dir)
|
||||
|
||||
# Check if there's only one directory inside the target directory
|
||||
contents = os.listdir(target_dir)
|
||||
if len(contents) == 1 and os.path.isdir(os.path.join(target_dir, contents[0])):
|
||||
nested_dir = os.path.join(target_dir, contents[0])
|
||||
# Move each file and sub-directory in the nested directory up to the target directory
|
||||
for item in os.listdir(nested_dir):
|
||||
shutil.move(os.path.join(nested_dir, item), os.path.join(target_dir, item))
|
||||
# Remove the now empty nested directory
|
||||
os.rmdir(nested_dir)
|
||||
|
||||
os.remove(model_path)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user