mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
Fix delete lora
This commit is contained in:
@@ -215,15 +215,23 @@ class ApiRoutes:
|
|||||||
|
|
||||||
deleted = []
|
deleted = []
|
||||||
main_file = patterns[0]
|
main_file = patterns[0]
|
||||||
main_path = os.path.join(target_dir, main_file)
|
main_path = os.path.join(target_dir, main_file).replace(os.sep, '/')
|
||||||
|
|
||||||
if os.path.exists(main_path):
|
if os.path.exists(main_path):
|
||||||
# Delete main file first
|
# Notify file monitor to ignore delete event
|
||||||
|
self.download_manager.file_monitor.handler.add_ignore_path(main_path, 0)
|
||||||
|
|
||||||
|
# Delete file
|
||||||
os.remove(main_path)
|
os.remove(main_path)
|
||||||
deleted.append(main_file)
|
deleted.append(main_path)
|
||||||
else:
|
else:
|
||||||
logger.warning(f"Model file not found: {main_file}")
|
logger.warning(f"Model file not found: {main_file}")
|
||||||
|
|
||||||
|
# Remove from cache
|
||||||
|
cache = await self.scanner.get_cached_data()
|
||||||
|
cache.raw_data = [item for item in cache.raw_data if item['file_path'] != main_path]
|
||||||
|
await cache.resort()
|
||||||
|
|
||||||
# Delete optional files
|
# Delete optional files
|
||||||
for pattern in patterns[1:]:
|
for pattern in patterns[1:]:
|
||||||
path = os.path.join(target_dir, pattern)
|
path = os.path.join(target_dir, pattern)
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ class LoraFileHandler(FileSystemEventHandler):
|
|||||||
|
|
||||||
def _should_ignore(self, path: str) -> bool:
|
def _should_ignore(self, path: str) -> bool:
|
||||||
"""Check if path should be ignored"""
|
"""Check if path should be ignored"""
|
||||||
logger.info(f"Checking ignore for {path}")
|
|
||||||
logger.info(f"Current ignore paths: {self._ignore_paths}")
|
|
||||||
real_path = os.path.realpath(path) # Resolve any symbolic links
|
real_path = os.path.realpath(path) # Resolve any symbolic links
|
||||||
return real_path.replace(os.sep, '/') in self._ignore_paths
|
return real_path.replace(os.sep, '/') in self._ignore_paths
|
||||||
|
|
||||||
@@ -37,14 +35,8 @@ class LoraFileHandler(FileSystemEventHandler):
|
|||||||
real_path = os.path.realpath(path) # Resolve any symbolic links
|
real_path = os.path.realpath(path) # Resolve any symbolic links
|
||||||
self._ignore_paths.add(real_path.replace(os.sep, '/'))
|
self._ignore_paths.add(real_path.replace(os.sep, '/'))
|
||||||
|
|
||||||
# Calculate timeout based on file size, with a minimum value
|
# Short timeout (e.g. 5 seconds) is sufficient to ignore the CREATE event
|
||||||
# Assuming average download speed of 1MB/s
|
timeout = 5
|
||||||
timeout = max(
|
|
||||||
self._min_ignore_timeout,
|
|
||||||
(file_size / self._download_speed) * 1.5 # Add 50% buffer
|
|
||||||
)
|
|
||||||
|
|
||||||
logger.debug(f"Adding {real_path} to ignore list for {timeout:.1f} seconds")
|
|
||||||
|
|
||||||
asyncio.get_event_loop().call_later(
|
asyncio.get_event_loop().call_later(
|
||||||
timeout,
|
timeout,
|
||||||
|
|||||||
Reference in New Issue
Block a user