diff --git a/__init__.py b/__init__.py index 957ec9d1..86d188aa 100644 --- a/__init__.py +++ b/__init__.py @@ -33,7 +33,7 @@ sys.path.append('../..') from torchvision.datasets.utils import download_url # ensure .js -print("### Loading: ComfyUI-Manager (V0.18.2)") +print("### Loading: ComfyUI-Manager (V0.19)") comfy_ui_required_revision = 1240 comfy_ui_revision = "Unknown" @@ -302,7 +302,7 @@ import zipfile import urllib.request -def get_model_path(data): +def get_model_dir(data): if data['save_path'] != 'default': base_model = os.path.join(folder_paths.models_dir, data['save_path']) else: @@ -330,8 +330,13 @@ def get_model_path(data): elif model_type == "embeddings": base_model = folder_paths.folder_names_and_paths["embeddings"][0][0] else: - base_model = None + base_model = "etc" + return base_model + + +def get_model_path(data): + base_model = get_model_dir(data) return os.path.join(base_model, data['filename']) @@ -933,14 +938,24 @@ async def install_model(request): res = False - if model_path is not None: - print(f"Install model '{json_data['name']}' into '{model_path}'") - res = download_url_with_agent(json_data['url'], model_path) - else: - print(f"Model installation error: invalid model type - {json_data['type']}") + try: + if model_path is not None: + print(f"Install model '{json_data['name']}' into '{model_path}'") - if res: - return web.json_response({}, content_type='application/json') + if json_data['url'].startswith('https://github.com') or json_data['url'].startswith('https://huggingface.co'): + model_dir = get_model_dir(json_data) + download_url(json_data['url'], model_dir) + return web.json_response({}, content_type='application/json') + else: + res = download_url_with_agent(json_data['url'], model_path) + else: + print(f"Model installation error: invalid model type - {json_data['type']}") + + if res: + return web.json_response({}, content_type='application/json') + except Exception as e: + print(f"[ERROR] {e}") + pass return web.Response(status=400) diff --git a/js/comfyui-manager.js b/js/comfyui-manager.js index faf4aeea..5cf3d916 100644 --- a/js/comfyui-manager.js +++ b/js/comfyui-manager.js @@ -111,6 +111,7 @@ async function install_custom_node(target, caller, mode) { async function updateComfyUI() { update_comfyui_button.innerText = "Updating ComfyUI..."; update_comfyui_button.disabled = true; + update_comfyui_button.style.backgroundColor = "gray"; try { const response = await api.fetchApi('/comfyui_manager/update_comfyui'); @@ -140,12 +141,14 @@ async function updateComfyUI() { finally { update_comfyui_button.disabled = false; update_comfyui_button.innerText = "Update ComfyUI"; + update_comfyui_button.style.backgroundColor = ""; } } -async function fetchUpdates() { +async function fetchUpdates(update_check_checkbox) { fetch_updates_button.innerText = "Fetching updates..."; fetch_updates_button.disabled = true; + fetch_updates_button.style.backgroundColor = "gray"; try { var mode = "url"; @@ -163,6 +166,7 @@ async function fetchUpdates() { if(response.status == 201) { app.ui.dialog.show('There is an updated extension available.'); app.ui.dialog.element.style.zIndex = 9999; + update_check_checkbox.checked = false; } else { app.ui.dialog.show('All extensions are already up-to-date with the latest versions.'); @@ -172,13 +176,14 @@ async function fetchUpdates() { return true; } catch(exception) { - app.ui.dialog.show(`Failed to update ComfyUI / ${exception}`); + app.ui.dialog.show(`Failed to update custom nodes / ${exception}`); app.ui.dialog.element.style.zIndex = 9999; return false; } finally { fetch_updates_button.disabled = false; fetch_updates_button.innerText = "Fetch Updates"; + fetch_updates_button.style.backgroundColor = ""; } } @@ -338,6 +343,8 @@ class CustomNodesInstaller extends ComfyDialog { $el('br')]); msg.style.height = '100px'; msg.style.verticalAlign = 'middle'; + msg.style.color = "var(--fg-color)"; + this.element.appendChild(msg); // invalidate @@ -1343,6 +1350,7 @@ class ManagerMenuDialog extends ComfyDialog { this.update_check_checkbox = $el("input",{type:'checkbox', id:"skip_update_check"},[]) const uc_checkbox_text = $el("label",{},[" Skip update check"]) uc_checkbox_text.style.color = "var(--fg-color)"; + this.update_check_checkbox.checked = true; update_comfyui_button = $el("button", { @@ -1357,7 +1365,7 @@ class ManagerMenuDialog extends ComfyDialog { type: "button", textContent: "Fetch Updates", onclick: - () => fetchUpdates() + () => fetchUpdates(this.update_check_checkbox) }); let preview_combo = document.createElement("select");