Add filename to download tasks and progress list

This commit is contained in:
Arslan Ablikim
2024-02-06 20:09:25 +08:00
parent 6ca34f4055
commit d0ed4e4df0
4 changed files with 16 additions and 6 deletions
+2 -2
View File
@@ -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()
+1
View File
@@ -3,6 +3,7 @@ import { api } from "/scripts/api.js";
export type InstallModelsApiInput = {
save_path: string;
filename: string;
url: string;
file_hash?: string;
};
@@ -92,6 +92,7 @@ export default function InatallModelsModal({
}
installModelsApi({
file_hash: file.current?.SHA256,
filename: version,
save_path: folderPath,
url,
});
@@ -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)