mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
Enhance preview image upload by deleting existing previews and updating UI state management
This commit is contained in:
@@ -429,6 +429,16 @@ class ModelRouteUtils:
|
||||
)
|
||||
extension = '.webp' # Use .webp without .preview part
|
||||
|
||||
# Delete any existing preview files for this model
|
||||
for ext in PREVIEW_EXTENSIONS:
|
||||
existing_preview = os.path.join(folder, base_name + ext)
|
||||
if os.path.exists(existing_preview):
|
||||
try:
|
||||
os.remove(existing_preview)
|
||||
logger.info(f"Deleted existing preview: {existing_preview}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to delete existing preview {existing_preview}: {e}")
|
||||
|
||||
preview_path = os.path.join(folder, base_name + extension).replace(os.sep, '/')
|
||||
|
||||
with open(preview_path, 'wb') as f:
|
||||
@@ -449,8 +459,7 @@ class ModelRouteUtils:
|
||||
logger.error(f"Error updating metadata: {e}")
|
||||
|
||||
# Update preview URL in scanner cache
|
||||
if hasattr(scanner, 'update_preview_in_cache'):
|
||||
await scanner.update_preview_in_cache(model_path, preview_path)
|
||||
await scanner.update_preview_in_cache(model_path, preview_path)
|
||||
|
||||
return web.json_response({
|
||||
"success": True,
|
||||
|
||||
Reference in New Issue
Block a user