mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-20 18:51:26 -03:00
feat(recipes): add reconnect remediation paths for missing recipe LoRAs
- Snapshot pre-rematch entry state (reconnectSnapshot) so rematched entries can be undone via the existing restore flow - Bulk missing-LoRA downloads mark unresolvable failures hash-invalid, flipping those entries from download to reconnect candidacy - Recipe modal always offers a reconnect action next to download for missing LoRA entries - Rematch runs collect an opt-in relaxed-matching choice (also reconnect missing models by file name) via a pre-run options dialog on the global, bulk and single-recipe entries - L4 (filename-level) matches are listed in a results dialog with per-entry undo
This commit is contained in:
@@ -74,6 +74,26 @@ async def _read_preview_dims(path: str) -> Optional[Tuple[int, int]]:
|
||||
return await asyncio.to_thread(ExifUtils.get_image_dimensions, path)
|
||||
|
||||
|
||||
async def _parse_relaxed_flag(request: web.Request) -> bool:
|
||||
"""Read the relaxed-rematch flag from the JSON body or query string.
|
||||
|
||||
The flag defaults to False (strict candidacy). A JSON body value wins;
|
||||
``?relaxed=true`` is honored as a fallback so GET-only clients can opt
|
||||
in. Body parse failures (empty/invalid JSON) are treated as "no flag".
|
||||
"""
|
||||
relaxed = False
|
||||
if request.can_read_body:
|
||||
try:
|
||||
data = await request.json()
|
||||
except Exception: # noqa: BLE001 - any parse failure means no flag
|
||||
data = None
|
||||
if isinstance(data, dict):
|
||||
relaxed = bool(data.get("relaxed"))
|
||||
if not relaxed:
|
||||
relaxed = request.query.get("relaxed", "").lower() == "true"
|
||||
return relaxed
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RecipeHandlerSet:
|
||||
"""Group of handlers providing recipe route implementations."""
|
||||
@@ -812,6 +832,8 @@ class RecipeManagementHandler:
|
||||
|
||||
recipe_scanner.reset_cancellation()
|
||||
|
||||
relaxed = await _parse_relaxed_flag(request)
|
||||
|
||||
async def progress_callback(data):
|
||||
await self._ws_manager.broadcast_recipe_rematch_progress(data)
|
||||
|
||||
@@ -819,7 +841,8 @@ class RecipeManagementHandler:
|
||||
async def run_rematch():
|
||||
try:
|
||||
await recipe_scanner.rematch_all_recipes(
|
||||
progress_callback=progress_callback
|
||||
progress_callback=progress_callback,
|
||||
relaxed=relaxed,
|
||||
)
|
||||
except Exception as e:
|
||||
self._logger.error(
|
||||
@@ -892,7 +915,13 @@ class RecipeManagementHandler:
|
||||
status=400,
|
||||
)
|
||||
|
||||
result = await recipe_scanner.rematch_recipes_bulk(recipe_ids)
|
||||
relaxed = bool(data.get("relaxed")) or (
|
||||
request.query.get("relaxed", "").lower() == "true"
|
||||
)
|
||||
|
||||
result = await recipe_scanner.rematch_recipes_bulk(
|
||||
recipe_ids, relaxed=relaxed
|
||||
)
|
||||
return web.json_response(result)
|
||||
except Exception as exc:
|
||||
self._logger.error(
|
||||
@@ -921,7 +950,10 @@ class RecipeManagementHandler:
|
||||
)
|
||||
|
||||
recipe_id = request.match_info["recipe_id"]
|
||||
result = await recipe_scanner.rematch_recipe_by_id(recipe_id)
|
||||
relaxed = await _parse_relaxed_flag(request)
|
||||
result = await recipe_scanner.rematch_recipe_by_id(
|
||||
recipe_id, relaxed=relaxed
|
||||
)
|
||||
return web.json_response(result)
|
||||
except RecipeNotFoundError as exc:
|
||||
return web.json_response({"success": False, "error": str(exc)}, status=404)
|
||||
|
||||
Reference in New Issue
Block a user