From d0ed4e4df0c1e1013425d2d65aae8d837c599ae2 Mon Sep 17 00:00:00 2001 From: Arslan Ablikim Date: Tue, 6 Feb 2024 20:09:25 +0800 Subject: [PATCH] Add filename to download tasks and progress list --- service/model_manager/model_installer.py | 4 ++-- ui/src/model-manager/api/modelsApi.ts | 1 + .../install-models/InatallModelsModal.tsx | 1 + .../model-manager/install-models/ModelCard.tsx | 16 ++++++++++++---- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/service/model_manager/model_installer.py b/service/model_manager/model_installer.py index e2167c6..ea95fdb 100644 --- a/service/model_manager/model_installer.py +++ b/service/model_manager/model_installer.py @@ -97,7 +97,7 @@ async def install_model(request): with download_tasks_lock: # Add the task to the list - download_tasks.append({ 'url': url, 'save_path': save_path }) + download_tasks.append({ 'url': url, 'save_path': save_path, 'filename': json_data['filename'] }) # If the previous thread is not active, start a new one if download_thread is None or not download_thread.is_alive(): @@ -252,7 +252,7 @@ def send_download_status(data): with download_tasks_lock: progress_list = [data] for task in download_tasks: - progress_list.append({'save_path': task['save_path'], 'progress': 0}) + progress_list.append({'save_path': task['filename'], 'progress': 0}) send_ws('download_progress', progress_list) loop = asyncio.get_event_loop() diff --git a/ui/src/model-manager/api/modelsApi.ts b/ui/src/model-manager/api/modelsApi.ts index 2c9b97a..779e41a 100644 --- a/ui/src/model-manager/api/modelsApi.ts +++ b/ui/src/model-manager/api/modelsApi.ts @@ -3,6 +3,7 @@ import { api } from "/scripts/api.js"; export type InstallModelsApiInput = { save_path: string; + filename: string; url: string; file_hash?: string; }; diff --git a/ui/src/model-manager/install-models/InatallModelsModal.tsx b/ui/src/model-manager/install-models/InatallModelsModal.tsx index 6745702..40bf4cd 100644 --- a/ui/src/model-manager/install-models/InatallModelsModal.tsx +++ b/ui/src/model-manager/install-models/InatallModelsModal.tsx @@ -92,6 +92,7 @@ export default function InatallModelsModal({ } installModelsApi({ file_hash: file.current?.SHA256, + filename: version, save_path: folderPath, url, }); diff --git a/ui/src/model-manager/install-models/ModelCard.tsx b/ui/src/model-manager/install-models/ModelCard.tsx index e34dcbb..5885948 100644 --- a/ui/src/model-manager/install-models/ModelCard.tsx +++ b/ui/src/model-manager/install-models/ModelCard.tsx @@ -49,13 +49,21 @@ export default function ModelCard({ console.error("no file is find by name", selectedFile); return; } - let SHA256; + let fileData: FileEssential; if (isCivitVersion(curFile)) { - SHA256 = curFile.files?.[0].hashes?.SHA256; + fileData = { + id: curFile.id, + SHA256: curFile.files?.[0].hashes?.SHA256, + name: curFile.files?.[0].name, + }; } else { - SHA256 = curFile.hashes?.[2]; + fileData = { + id: curFile.id, + SHA256: curFile.hashes?.[2], + name: `${model.name} ${curFile.name}`, + }; } - onClickInstallModel({ ...curFile, SHA256 }, model); + onClickInstallModel(fileData, model); }, [selectedFile]); const sizeKB = curFile && isCivitVersion(curFile)