mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
Fix bug
This commit is contained in:
@@ -330,7 +330,7 @@ class ApiRoutes:
|
|||||||
with open(metadata_path, 'w', encoding='utf-8') as f:
|
with open(metadata_path, 'w', encoding='utf-8') as f:
|
||||||
json.dump(local_metadata, f, indent=2, ensure_ascii=False)
|
json.dump(local_metadata, f, indent=2, ensure_ascii=False)
|
||||||
|
|
||||||
await self.scanner.update_single_lora_cache(local_metadata['file_path'], local_metadata)
|
await self.scanner.update_single_lora_cache(local_metadata['file_path'], local_metadata['file_path'], local_metadata)
|
||||||
|
|
||||||
async def fetch_all_civitai(self, request: web.Request) -> web.Response:
|
async def fetch_all_civitai(self, request: web.Request) -> web.Response:
|
||||||
"""Fetch CivitAI metadata for all loras in the background"""
|
"""Fetch CivitAI metadata for all loras in the background"""
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ class LoraScanner:
|
|||||||
if os.path.exists(source_metadata):
|
if os.path.exists(source_metadata):
|
||||||
target_metadata = os.path.join(target_path, f"{base_name}.metadata.json")
|
target_metadata = os.path.join(target_path, f"{base_name}.metadata.json")
|
||||||
shutil.move(source_metadata, target_metadata)
|
shutil.move(source_metadata, target_metadata)
|
||||||
lora_data = await self._update_metadata_paths(target_metadata, target_lora)
|
metadata = await self._update_metadata_paths(target_metadata, target_lora)
|
||||||
|
|
||||||
# Move preview file if exists
|
# Move preview file if exists
|
||||||
preview_extensions = ['.preview.png', '.preview.jpeg', '.preview.jpg', '.preview.mp4',
|
preview_extensions = ['.preview.png', '.preview.jpeg', '.preview.jpg', '.preview.mp4',
|
||||||
@@ -382,7 +382,7 @@ class LoraScanner:
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Update cache
|
# Update cache
|
||||||
await self.update_single_lora_cache(source_path, lora_data)
|
await self.update_single_lora_cache(source_path, target_lora, metadata)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -390,14 +390,14 @@ class LoraScanner:
|
|||||||
logger.error(f"Error moving model: {e}", exc_info=True)
|
logger.error(f"Error moving model: {e}", exc_info=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def update_single_lora_cache(self, file_path: str, metadata: Dict) -> bool:
|
async def update_single_lora_cache(self, original_path: str, new_path: str, metadata: Dict) -> bool:
|
||||||
cache = await self.get_cached_data()
|
cache = await self.get_cached_data()
|
||||||
cache.raw_data = [
|
cache.raw_data = [
|
||||||
item for item in cache.raw_data
|
item for item in cache.raw_data
|
||||||
if item['file_path'] != file_path
|
if item['file_path'] != original_path
|
||||||
]
|
]
|
||||||
if metadata:
|
if metadata:
|
||||||
metadata['folder'] = self._calculate_folder(file_path)
|
metadata['folder'] = self._calculate_folder(new_path)
|
||||||
cache.raw_data.append(metadata)
|
cache.raw_data.append(metadata)
|
||||||
all_folders = set(cache.folders)
|
all_folders = set(cache.folders)
|
||||||
all_folders.add(metadata['folder'])
|
all_folders.add(metadata['folder'])
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ export async function refreshLoras() {
|
|||||||
|
|
||||||
export async function refreshSingleLoraMetadata(filePath) {
|
export async function refreshSingleLoraMetadata(filePath) {
|
||||||
try {
|
try {
|
||||||
|
state.loadingManager.showSimpleLoading('Refreshing metadata...');
|
||||||
const response = await fetch('/api/fetch-civitai', {
|
const response = await fetch('/api/fetch-civitai', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -314,5 +315,8 @@ export async function refreshSingleLoraMetadata(filePath) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error refreshing metadata:', error);
|
console.error('Error refreshing metadata:', error);
|
||||||
showToast(error.message, 'error');
|
showToast(error.message, 'error');
|
||||||
|
} finally {
|
||||||
|
state.loadingManager.hide();
|
||||||
|
state.loadingManager.restoreProgressBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user