Fix delete lora

This commit is contained in:
Will Miao
2025-02-23 16:10:58 +08:00
parent 3871557868
commit 5694f6d4d2
2 changed files with 13 additions and 13 deletions

View File

@@ -215,14 +215,22 @@ class ApiRoutes:
deleted = []
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):
# 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)
deleted.append(main_file)
deleted.append(main_path)
else:
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
for pattern in patterns[1:]: