Skip to content

Commit

Permalink
Merge pull request #9 from TNG/fix/DownloadDialogBugs
Browse files Browse the repository at this point in the history
Minimal improvements and fixes
  • Loading branch information
julianbollig authored Dec 2, 2024
2 parents eb38199 + f129a88 commit 9a82532
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions WebUI/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dist-ssr
*.local
release/
ComfyUI/
*.nsh

# Editor directories and files
.vscode/*
Expand Down
2 changes: 1 addition & 1 deletion WebUI/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function postImageToEnhance(imageUrl: string) {
function showDownloadModelConfirm(downList: DownloadModelParam[], success?: () => void, fail?: () => void) {
showDowloadDlg.value = true;
nextTick(() => {
downloadDigCompt.value!.showConfirm(downList, success, fail);
downloadDigCompt.value!.showConfirmDialog(downList, success, fail);
});
}
Expand Down
2 changes: 1 addition & 1 deletion WebUI/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"DOWNLOADER_FOR_IMAGE_PREVIEW": "Bildvorschau Modell",
"DOWNLOADER_FOR_IMAGE_UPSCALE": "Bild Upscale Modell",
"DOWNLOADER_FOR_IMAGE_LORA": "Schnelles Bild Modell",
"DOWNLOADER_DONWLOAD_TASK_PROGRESS": "Download Modell vollständig",
"DOWNLOADER_DONWLOAD_TASK_PROGRESS": "Modell Downloads abgeschlossen",
"RAG_FILE_TOTAL_FORMAT": "Datei total: {total}",
"RAG_DRAG_UPLOAD": "Ziehen Sie Dateien zum Hochladen",
"RAG_DRAG_UPLOAD_UNSUPPORTED": "Das aktuelle Programm wird mit Administratorrechten gestartet. Aufgrund von Windows-UAC-Einschränkungen kann der Drag-and-Drop-Upload nicht verwendet werden. Bitte verwenden Sie die Schaltfläche „Hinzufügen“ oben, um Dateien hochzuladen.",
Expand Down
2 changes: 1 addition & 1 deletion WebUI/src/assets/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"DOWNLOADER_FOR_IMAGE_PREVIEW":"Image Preview Model",
"DOWNLOADER_FOR_IMAGE_UPSCALE":"Image Upscale Model",
"DOWNLOADER_FOR_IMAGE_LORA": "Fast Image Model",
"DOWNLOADER_DONWLOAD_TASK_PROGRESS":"Download Model Complete",
"DOWNLOADER_DONWLOAD_TASK_PROGRESS":"Model Downloads Complete",
"RAG_FILE_TOTAL_FORMAT": "File total: {total}",
"RAG_DRAG_UPLOAD": "Drag files to upload",
"RAG_DRAG_UPLOAD_UNSUPPORTED": "The current program is started with administrator privileges. Due to Windows UAC limitations, drag and drop upload cannot be used. Please use the add button at the top to upload files.",
Expand Down
2 changes: 1 addition & 1 deletion WebUI/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"DOWNLOADER_FOR_IMAGE_PREVIEW": "Modelo de vista previa de imagen",
"DOWNLOADER_FOR_IMAGE_UPSCALE": "Modelo de imagen aumentada",
"DOWNLOADER_FOR_IMAGE_LORA": "Modelo de imagen rápida",
"DOWNLOADER_DONWLOAD_TASK_PROGRESS": "Descarga del modelo completada",
"DOWNLOADER_DONWLOAD_TASK_PROGRESS": "Descargas del modelo completadas",
"RAG_FILE_TOTAL_FORMAT": "Archivos totales: {total}",
"RAG_DRAG_UPLOAD": "Arrastra los archivos para cargar",
"RAG_DRAG_UPLOAD_UNSUPPORTED": "El programa actual se ejecuta con privilegios de administrador. Debido a las limitaciones de UAC de Windows, no es posible utilizar la carga mediante arrastre. Usa el botón de arriba \"Agregar\" para cargar los archivos.",
Expand Down
16 changes: 10 additions & 6 deletions WebUI/src/components/DownloadDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}}</button>
</div>
</div>
<div v-else="hashError" class="flex flex-col items-center justify-center gap-4">
<div v-else-if="hashError" class="flex flex-col items-center justify-center gap-4">
<p>{{ errorText }}</p>
<button @click="close" class="bg-red-500 py-1 px-4">{{ i18nState.COM_CLOSE }}</button>
</div>
Expand Down Expand Up @@ -149,13 +149,16 @@ function dataProcess(line: string) {
break;
case "error":
hashError.value = true;
abortController?.abort();
fetch(`${globalSetup.apiHost}/api/stopDownloadModel`)
downloadReject && downloadReject({ type: "error", error: errorText.value });
switch (data.err_type) {
case "not_enough_disk_space":
errorText.value = i18nState.ERR_NOT_ENOUGH_DISK_SPACE.replace("{requires_space}", data.requires_space).replace("{free_space}", data.free_space);
break;
case "download_exception":
errorText.value = i18nState.ERR_DOWNLOAD_FAILED;
toast.error(i18nState.ERR_DOWNLOAD_FAILED);
break;
case "runtime_error":
errorText.value = i18nState.ERROR_RUNTIME_ERROR;
Expand All @@ -171,7 +174,7 @@ function dataProcess(line: string) {
let downloadResolve: undefined | (() => void);
let downloadReject: ((args: DownloadFailedParams) => void) | undefined
async function showConfirm(downList: DownloadModelParam[], success?: () => void, fail?: (args: DownloadFailedParams) => void) {
async function showConfirmDialog(downList: DownloadModelParam[], success?: () => void, fail?: (args: DownloadFailedParams) => void) {
if (downloding) {
toast.error(i18nState.DOWNLOADER_CONFLICT);
fail && fail({ type: "conflict" })
Expand All @@ -182,6 +185,7 @@ async function showConfirm(downList: DownloadModelParam[], success?: () => void,
showComfirm.value = true;
hashError.value = false;
percent.value = 0;
taskPercent.value = 0;
downloadList.value = downList.map((item) => {
return { repo_id: item.repo_id, type: item.type, size: "???", backend: item.backend , }
});
Expand Down Expand Up @@ -308,16 +312,16 @@ function confirmDownload() {
function cancelDownload() {
abortController?.abort();
fetch(`${globalSetup.apiHost}/api/stopDownloadModel`)
emits("close");
downloadReject && downloadReject({ type: "cancelDownload" });
emits("close");
}
function close() {
downloadReject && downloadReject({ type: "error", error: errorText.value });
emits("close");
}
defineExpose({ showConfirm, download });
defineExpose({ showConfirmDialog, download });
</script>
<style scoped>
table {
Expand Down
4 changes: 1 addition & 3 deletions service/model_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ def download(self, repo_id: str, model_type: int, backend: str, thread_count: in
if cache_item is None:
file_list = list()
self.enum_file_list(file_list, repo_id, model_type)
model_list_cache.__setitem__(
{"size": self.total_size, "queue": self.file_queue}
)
model_list_cache.__setitem__(key, {"size": self.total_size, "queue": self.file_queue})
else:
self.total_size = cache_item["size"]
file_list: list = cache_item["queue"]
Expand Down

0 comments on commit 9a82532

Please sign in to comment.