mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
Merge pull request #231 from PredatorIWD/fix-crash-on-symlinks
Don't crash completely if a symlink resolve fails
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
from server import PromptServer # type: ignore
|
from server import PromptServer # type: ignore
|
||||||
|
|
||||||
from .config import config
|
from .config import config
|
||||||
from .routes.lora_routes import LoraRoutes
|
from .routes.lora_routes import LoraRoutes
|
||||||
from .routes.api_routes import ApiRoutes
|
from .routes.api_routes import ApiRoutes
|
||||||
@@ -11,9 +16,6 @@ from .routes.example_images_routes import ExampleImagesRoutes
|
|||||||
from .services.service_registry import ServiceRegistry
|
from .services.service_registry import ServiceRegistry
|
||||||
from .services.settings_manager import settings
|
from .services.settings_manager import settings
|
||||||
from .utils.example_images_migration import ExampleImagesMigration
|
from .utils.example_images_migration import ExampleImagesMigration
|
||||||
import logging
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -95,10 +97,14 @@ class LoraManager:
|
|||||||
route_path = f'/loras_static/link_{link_idx["lora"]}/preview'
|
route_path = f'/loras_static/link_{link_idx["lora"]}/preview'
|
||||||
link_idx["lora"] += 1
|
link_idx["lora"] += 1
|
||||||
|
|
||||||
app.router.add_static(route_path, target_path)
|
try:
|
||||||
logger.info(f"Added static route for link target {route_path} -> {target_path}")
|
app.router.add_static(route_path, Path(target_path).resolve(strict=False))
|
||||||
config.add_route_mapping(target_path, route_path)
|
logger.info(f"Added static route for link target {route_path} -> {target_path}")
|
||||||
added_targets.add(target_path)
|
config.add_route_mapping(target_path, route_path)
|
||||||
|
added_targets.add(target_path)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Failed to add static route on initialization for {target_path}: {e}")
|
||||||
|
continue
|
||||||
|
|
||||||
# Add static route for plugin assets
|
# Add static route for plugin assets
|
||||||
app.router.add_static('/loras_static', config.static_path)
|
app.router.add_static('/loras_static', config.static_path)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
@@ -280,10 +281,14 @@ class StandaloneLoraManager(LoraManager):
|
|||||||
# Display path with forward slashes for consistency
|
# Display path with forward slashes for consistency
|
||||||
display_target = target_path.replace('\\', '/')
|
display_target = target_path.replace('\\', '/')
|
||||||
|
|
||||||
app.router.add_static(route_path, target_path)
|
try:
|
||||||
logger.info(f"Added static route for link target {route_path} -> {display_target}")
|
app.router.add_static(route_path, Path(target_path).resolve(strict=False))
|
||||||
config.add_route_mapping(target_path, route_path)
|
logger.info(f"Added static route for link target {route_path} -> {display_target}")
|
||||||
added_targets.add(norm_target)
|
config.add_route_mapping(target_path, route_path)
|
||||||
|
added_targets.add(norm_target)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Failed to add static route on initialization for {target_path}: {e}")
|
||||||
|
continue
|
||||||
|
|
||||||
# Add static route for plugin assets
|
# Add static route for plugin assets
|
||||||
app.router.add_static('/loras_static', config.static_path)
|
app.router.add_static('/loras_static', config.static_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user