fix: reduce download timeout to 5s, update progress per LoRA (#52)

5K images at 15s timeout was painfully slow. Reduced to 5s fail-fast.
Progress now updates for every LoRA with image count, not every 5th.
This commit is contained in:
Vito Sansevero
2026-04-03 08:56:09 -07:00
parent b24343dc6c
commit 195cf2adb4
2 changed files with 17 additions and 14 deletions
+16 -13
View File
@@ -321,19 +321,22 @@ class LoraIntegrationMixin:
self.logger.warning(f"Failed to import LoRA {model_name}: {e}")
skipped += 1
# Progress update every 5 items or at the end
if (i + 1) % 5 == 0 or i == total - 1:
progress = int(5 + (90 * (i + 1) / max(total, 1)))
await send_progress(
{
"type": "progress",
"status": f"Processing: {model_name}",
"progress": progress,
"processed": i + 1,
"imported": imported,
"skipped": skipped,
}
)
# Progress update for every LoRA
progress = int(5 + (90 * (i + 1) / max(total, 1)))
img_count = len(all_images)
status = f"{model_name}"
if img_count:
status += f" ({img_count} images)"
await send_progress(
{
"type": "progress",
"status": status,
"progress": progress,
"processed": i + 1,
"imported": imported,
"skipped": skipped,
}
)
await send_progress(
{
+1 -1
View File
@@ -347,7 +347,7 @@ def download_civitai_images(
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req, timeout=15) as resp:
with urllib.request.urlopen(req, timeout=5) as resp:
local_path.write_bytes(resp.read())
downloaded.append(str(local_path.resolve()))
except Exception as e: