mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-06-14 06:29:25 -03:00
fix(save-image): sanitize invalid filename chars from %pprompt%, %nprompt%, %model% patterns (#978)
This commit is contained in:
@@ -11,7 +11,7 @@ from ..metadata_collector.metadata_processor import MetadataProcessor
|
|||||||
from ..metadata_collector import get_metadata
|
from ..metadata_collector import get_metadata
|
||||||
from ..utils.constants import CARD_PREVIEW_WIDTH
|
from ..utils.constants import CARD_PREVIEW_WIDTH
|
||||||
from ..utils.exif_utils import ExifUtils
|
from ..utils.exif_utils import ExifUtils
|
||||||
from ..utils.utils import calculate_recipe_fingerprint
|
from ..utils.utils import calculate_recipe_fingerprint, sanitize_folder_name
|
||||||
from PIL import Image, PngImagePlugin
|
from PIL import Image, PngImagePlugin
|
||||||
import piexif
|
import piexif
|
||||||
import logging
|
import logging
|
||||||
@@ -309,12 +309,14 @@ class SaveImageLM:
|
|||||||
filename = filename.replace(segment, str(h))
|
filename = filename.replace(segment, str(h))
|
||||||
elif key == "pprompt" and "prompt" in metadata_dict:
|
elif key == "pprompt" and "prompt" in metadata_dict:
|
||||||
prompt = metadata_dict.get("prompt", "").replace("\n", " ")
|
prompt = metadata_dict.get("prompt", "").replace("\n", " ")
|
||||||
|
prompt = sanitize_folder_name(prompt)
|
||||||
if len(parts) >= 2:
|
if len(parts) >= 2:
|
||||||
length = int(parts[1])
|
length = int(parts[1])
|
||||||
prompt = prompt[:length]
|
prompt = prompt[:length]
|
||||||
filename = filename.replace(segment, prompt.strip())
|
filename = filename.replace(segment, prompt.strip())
|
||||||
elif key == "nprompt" and "negative_prompt" in metadata_dict:
|
elif key == "nprompt" and "negative_prompt" in metadata_dict:
|
||||||
prompt = metadata_dict.get("negative_prompt", "").replace("\n", " ")
|
prompt = metadata_dict.get("negative_prompt", "").replace("\n", " ")
|
||||||
|
prompt = sanitize_folder_name(prompt)
|
||||||
if len(parts) >= 2:
|
if len(parts) >= 2:
|
||||||
length = int(parts[1])
|
length = int(parts[1])
|
||||||
prompt = prompt[:length]
|
prompt = prompt[:length]
|
||||||
@@ -328,6 +330,7 @@ class SaveImageLM:
|
|||||||
model = "model_unavailable"
|
model = "model_unavailable"
|
||||||
else:
|
else:
|
||||||
model = os.path.splitext(os.path.basename(model_value))[0]
|
model = os.path.splitext(os.path.basename(model_value))[0]
|
||||||
|
model = sanitize_folder_name(model)
|
||||||
if len(parts) >= 2:
|
if len(parts) >= 2:
|
||||||
length = int(parts[1])
|
length = int(parts[1])
|
||||||
model = model[:length]
|
model = model[:length]
|
||||||
|
|||||||
Reference in New Issue
Block a user