mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 23:25:43 -03:00
fix: update recipe data structure to include source_path from metadata and improve loading messages
This commit is contained in:
@@ -550,7 +550,7 @@ class RecipeRoutes:
|
|||||||
with open(image_path, 'wb') as f:
|
with open(image_path, 'wb') as f:
|
||||||
f.write(optimized_image)
|
f.write(optimized_image)
|
||||||
|
|
||||||
# Create the recipe JSON
|
# Create the recipe data structure
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
|
|
||||||
# Format loras data according to the recipe.json format
|
# Format loras data according to the recipe.json format
|
||||||
@@ -606,6 +606,10 @@ class RecipeRoutes:
|
|||||||
if tags:
|
if tags:
|
||||||
recipe_data["tags"] = tags
|
recipe_data["tags"] = tags
|
||||||
|
|
||||||
|
# Add source_path if provided in metadata
|
||||||
|
if metadata.get("source_path"):
|
||||||
|
recipe_data["source_path"] = metadata.get("source_path")
|
||||||
|
|
||||||
# Save the recipe JSON
|
# Save the recipe JSON
|
||||||
json_filename = f"{recipe_id}.recipe.json"
|
json_filename = f"{recipe_id}.recipe.json"
|
||||||
json_path = os.path.join(recipes_dir, json_filename)
|
json_path = os.path.join(recipes_dir, json_filename)
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ from safetensors import safe_open
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
from .model_utils import determine_base_model
|
from .model_utils import determine_base_model
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
async def extract_lora_metadata(file_path: str) -> Dict:
|
async def extract_lora_metadata(file_path: str) -> Dict:
|
||||||
"""Extract essential metadata from safetensors file"""
|
"""Extract essential metadata from safetensors file"""
|
||||||
|
|||||||
@@ -907,17 +907,17 @@ export class ImportManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.loadingManager.showSimpleLoading(isDownloadOnly ? 'Preparing download...' : 'Saving recipe...');
|
// Show progress indicator
|
||||||
|
this.loadingManager.showSimpleLoading(isDownloadOnly ? 'Downloading LoRAs...' : 'Saving recipe...');
|
||||||
|
|
||||||
// If we're only downloading LoRAs for an existing recipe, skip the recipe save step
|
// Only send the complete recipe to save if not in download-only mode
|
||||||
if (!isDownloadOnly) {
|
if (!isDownloadOnly) {
|
||||||
// First save the recipe
|
// Create FormData object for saving recipe
|
||||||
// Create form data for save request
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
// Handle image data - either from file upload or from URL mode
|
// Add image data - depends on import mode
|
||||||
if (this.recipeImage) {
|
if (this.recipeImage) {
|
||||||
// File upload mode
|
// Direct upload
|
||||||
formData.append('image', this.recipeImage);
|
formData.append('image', this.recipeImage);
|
||||||
} else if (this.recipeData && this.recipeData.image_base64) {
|
} else if (this.recipeData && this.recipeData.image_base64) {
|
||||||
// URL mode with base64 data
|
// URL mode with base64 data
|
||||||
@@ -945,6 +945,15 @@ export class ImportManager {
|
|||||||
raw_metadata: this.recipeData.raw_metadata || {}
|
raw_metadata: this.recipeData.raw_metadata || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add source_path to metadata to track where the recipe was imported from
|
||||||
|
if (this.importMode === 'url') {
|
||||||
|
const urlInput = document.getElementById('imageUrlInput');
|
||||||
|
console.log("urlInput.value", urlInput.value);
|
||||||
|
if (urlInput && urlInput.value) {
|
||||||
|
completeMetadata.source_path = urlInput.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
formData.append('metadata', JSON.stringify(completeMetadata));
|
formData.append('metadata', JSON.stringify(completeMetadata));
|
||||||
|
|
||||||
// Send save request
|
// Send save request
|
||||||
|
|||||||
Reference in New Issue
Block a user