diff --git a/invokeai/app/api/routers/model_manager.py b/invokeai/app/api/routers/model_manager.py index 50ebe5ce64..3a701297cd 100644 --- a/invokeai/app/api/routers/model_manager.py +++ b/invokeai/app/api/routers/model_manager.py @@ -273,7 +273,7 @@ async def scan_for_models( scan_path: str = Query(description="Directory path to search for models", default=None), ) -> List[FoundModel]: path = pathlib.Path(scan_path) - if not scan_path or not path.is_dir(): + if not path.is_dir(): raise HTTPException( status_code=400, detail=f"The search path '{scan_path}' does not exist or is not directory", diff --git a/invokeai/backend/model_manager/search.py b/invokeai/backend/model_manager/search.py index 330cff4e08..ff2e7a1a5b 100644 --- a/invokeai/backend/model_manager/search.py +++ b/invokeai/backend/model_manager/search.py @@ -25,10 +25,10 @@ from abc import ABC, abstractmethod from logging import Logger from pathlib import Path from typing import Callable, Optional, Set, Union -from invokeai.app.services.config import InvokeAIAppConfig from pydantic import BaseModel, Field +from invokeai.app.services.config import InvokeAIAppConfig from invokeai.backend.util.logging import InvokeAILogger default_logger: Logger = InvokeAILogger.get_logger() @@ -167,15 +167,15 @@ class ModelSearch(ModelSearchBase): ): try: self.model_found(absolute_path) + return except KeyboardInterrupt: raise except Exception as e: self.logger.warning(str(e)) - finally: return for n in file_names: - if any([n.endswith(suffix) for suffix in {".ckpt", ".bin", ".pth", ".safetensors", ".pt"}]): + if n.endswith((".ckpt", ".bin", ".pth", ".safetensors", ".pt")): try: self.model_found(absolute_path / n) except KeyboardInterrupt: