From 80144809ade031fb7d26440755f12e54cd006a10 Mon Sep 17 00:00:00 2001 From: Dnak-jb Date: Sat, 14 Feb 2026 23:39:08 -0600 Subject: [PATCH] refactor: use uuid for temp filenames and fix alphabet typo Fixed a duplicate 'p' and missing 'w' in the manual alphabet string by removing it. Standardized logic to use uuid4().hex[:5] as seen in PreviewUI3D. --- comfy_api/latest/_ui.py | 5 ++--- nodes.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/comfy_api/latest/_ui.py b/comfy_api/latest/_ui.py index e238cdf3c..411dbe086 100644 --- a/comfy_api/latest/_ui.py +++ b/comfy_api/latest/_ui.py @@ -2,7 +2,6 @@ from __future__ import annotations import json import os -import random import uuid from io import BytesIO @@ -390,7 +389,7 @@ class PreviewImage(_UIOutput): def __init__(self, image: Image.Type, animated: bool = False, cls: type[ComfyNode] = None, **kwargs): self.values = ImageSaveHelper.save_images( image, - filename_prefix="ComfyUI_temp_" + ''.join(random.choice("abcdefghijklmnopqrstupvxyz") for _ in range(5)), + filename_prefix="ComfyUI_temp_" + uuid.uuid4().hex[:5], folder_type=FolderType.temp, cls=cls, compress_level=1, @@ -414,7 +413,7 @@ class PreviewAudio(_UIOutput): def __init__(self, audio: dict, cls: type[ComfyNode] = None, **kwargs): self.values = AudioSaveHelper.save_audio( audio, - filename_prefix="ComfyUI_temp_" + "".join(random.choice("abcdefghijklmnopqrstuvwxyz") for _ in range(5)), + filename_prefix="ComfyUI_temp_" + uuid.uuid4().hex[:5], folder_type=FolderType.temp, cls=cls, format="flac", diff --git a/nodes.py b/nodes.py index 91de7a9d7..5ea26a60a 100644 --- a/nodes.py +++ b/nodes.py @@ -11,7 +11,7 @@ import inspect import traceback import math import time -import random +import uuid import logging from PIL import Image, ImageOps, ImageSequence @@ -1683,7 +1683,7 @@ class PreviewImage(SaveImage): def __init__(self): self.output_dir = folder_paths.get_temp_directory() self.type = "temp" - self.prefix_append = "_temp_" + ''.join(random.choice("abcdefghijklmnopqrstupvxyz") for x in range(5)) + self.prefix_append = "_temp_" + uuid.uuid4().hex[:5] self.compress_level = 1 SEARCH_ALIASES = ["preview", "preview image", "show image", "view image", "display image", "image viewer"]