mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
Fix getting stuck when loras folder is empty
This commit is contained in:
@@ -52,8 +52,9 @@ class LoraRoutes:
|
|||||||
try:
|
try:
|
||||||
# 不等待缓存数据,直接检查缓存状态
|
# 不等待缓存数据,直接检查缓存状态
|
||||||
is_initializing = (
|
is_initializing = (
|
||||||
self.scanner._cache is None or
|
self.scanner._cache is None and
|
||||||
(hasattr(self.scanner, '_cache') and len(self.scanner._cache.raw_data) == 0)
|
(self.scanner._initialization_task is not None and
|
||||||
|
not self.scanner._initialization_task.done())
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_initializing:
|
if is_initializing:
|
||||||
|
|||||||
@@ -84,19 +84,31 @@ class LoraScanner:
|
|||||||
|
|
||||||
async def _initialize_cache(self) -> None:
|
async def _initialize_cache(self) -> None:
|
||||||
"""Initialize or refresh the cache"""
|
"""Initialize or refresh the cache"""
|
||||||
# Scan for new data
|
try:
|
||||||
raw_data = await self.scan_all_loras()
|
# Scan for new data
|
||||||
|
raw_data = await self.scan_all_loras()
|
||||||
# Update cache
|
|
||||||
self._cache = LoraCache(
|
# Update cache
|
||||||
raw_data=raw_data,
|
self._cache = LoraCache(
|
||||||
sorted_by_name=[],
|
raw_data=raw_data,
|
||||||
sorted_by_date=[],
|
sorted_by_name=[],
|
||||||
folders=[]
|
sorted_by_date=[],
|
||||||
)
|
folders=[]
|
||||||
|
)
|
||||||
# Call resort_cache to create sorted views
|
|
||||||
await self._cache.resort()
|
# Call resort_cache to create sorted views
|
||||||
|
await self._cache.resort()
|
||||||
|
|
||||||
|
self._initialization_task = None
|
||||||
|
logger.info("LoRA Manager: Cache initialization completed")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"LoRA Manager: Error initializing cache: {e}")
|
||||||
|
self._cache = LoraCache(
|
||||||
|
raw_data=[],
|
||||||
|
sorted_by_name=[],
|
||||||
|
sorted_by_date=[],
|
||||||
|
folders=[]
|
||||||
|
)
|
||||||
|
|
||||||
def fuzzy_match(self, text: str, pattern: str, threshold: float = 0.7) -> bool:
|
def fuzzy_match(self, text: str, pattern: str, threshold: float = 0.7) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user