From 98425f37b81db8e24ad70904762294ac0632fdc0 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Sun, 5 Oct 2025 07:29:11 +0800 Subject: [PATCH] fix(download-manager): improve handling of civitai payloads to avoid empty dictionaries --- py/utils/example_images_download_manager.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/py/utils/example_images_download_manager.py b/py/utils/example_images_download_manager.py index 57449412..6afe82d5 100644 --- a/py/utils/example_images_download_manager.py +++ b/py/utils/example_images_download_manager.py @@ -358,7 +358,8 @@ class DownloadManager: full_model = await MetadataUpdater.get_updated_model( model_hash, scanner ) - civitai_payload = (full_model or {}).get('civitai', {}) if full_model else {} + civitai_payload = (full_model or {}).get('civitai') if full_model else None + civitai_payload = civitai_payload or {} # If no local images, try to download from remote if civitai_payload.get('images'): @@ -378,7 +379,8 @@ class DownloadManager: updated_model = await MetadataUpdater.get_updated_model( model_hash, scanner ) - updated_civitai = (updated_model or {}).get('civitai', {}) if updated_model else {} + updated_civitai = (updated_model or {}).get('civitai') if updated_model else None + updated_civitai = updated_civitai or {} if updated_civitai.get('images'): # Retry download with updated metadata @@ -647,7 +649,8 @@ class DownloadManager: full_model = await MetadataUpdater.get_updated_model( model_hash, scanner ) - civitai_payload = (full_model or {}).get('civitai', {}) if full_model else {} + civitai_payload = (full_model or {}).get('civitai') if full_model else None + civitai_payload = civitai_payload or {} # If no local images, try to download from remote if civitai_payload.get('images'): @@ -667,7 +670,8 @@ class DownloadManager: updated_model = await MetadataUpdater.get_updated_model( model_hash, scanner ) - updated_civitai = (updated_model or {}).get('civitai', {}) if updated_model else {} + updated_civitai = (updated_model or {}).get('civitai') if updated_model else None + updated_civitai = updated_civitai or {} if updated_civitai.get('images'): # Retry download with updated metadata