feat(recipe_scanner): prioritize local sibling images and persist repairs

Updated image path resolution logic to prioritize local sibling images in the same directory as recipes. When a stored image path differs from a local sibling, the system now automatically updates the recipe file to use the local path and persists this repair. This improves reliability when recipe assets are moved or reorganized, ensuring images remain accessible even if original paths become invalid.
This commit is contained in:
Will Miao
2026-01-08 15:53:01 +08:00
parent b57a317c82
commit f62b3f62be
2 changed files with 47 additions and 30 deletions

View File

@@ -40,10 +40,16 @@ class RecipeCard {
const missingLorasCount = loras.filter(lora => !lora.inLibrary && !lora.isDeleted).length;
const allLorasAvailable = missingLorasCount === 0 && lorasCount > 0;
// Ensure file_url exists, fallback to file_path if needed
const previewUrl = this.recipe.file_url ||
(this.recipe.file_path ? `/loras_static/root1/preview/${this.recipe.file_path.split('/').pop()}` :
'/loras_static/images/no-preview.png');
// Ensure file_url exists, fallback to API URL if needed
let previewUrl = this.recipe.file_url;
if (!previewUrl) {
if (this.recipe.file_path) {
const encodedPath = encodeURIComponent(this.recipe.file_path.replace(/\\/g, '/'));
previewUrl = `/api/lm/previews?path=${encodedPath}`;
} else {
previewUrl = '/loras_static/images/no-preview.png';
}
}
const isDuplicatesMode = getCurrentPageState().duplicatesMode;
const autoplayOnHover = state?.global?.settings?.autoplay_on_hover === true;