From 121670e72ea716f2a98bdf3bb146d427813d783f Mon Sep 17 00:00:00 2001 From: Moser9815 Date: Mon, 24 Aug 2026 21:50:44 -0400 Subject: [PATCH] Fix PREVIEW_DIR so preview cleanup targets the served folder PREVIEW_DIR pointed at Playground\Viewer\public\previews, but the app lives at Playground\Apps\Viewer. The clear-on-workflow-start in styles_pipe has therefore been sweeping an empty folder since the app moved, while real previews accumulated untouched in the served one - 9 files / 4.26 MB found and removed. Resolves against a candidate list now (RM_PREVIEW_DIR, current location, legacy), first existing wins, so moving the app again cannot silently resurrect this. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_012uM7Ru1JYn48n6c5Rzwd99 --- nodes/progress_reporter.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/nodes/progress_reporter.py b/nodes/progress_reporter.py index ae8f980..9bff1a6 100644 --- a/nodes/progress_reporter.py +++ b/nodes/progress_reporter.py @@ -16,7 +16,28 @@ except ImportError: HAS_REQUESTS = False VIEWER_URL = "http://127.0.0.1:3001/api/comfy-progress" -PREVIEW_DIR = r"C:\Users\rober\Playground\Viewer\public\previews" + +# The Viewer serves previews from /public/previews. This pointed at +# Playground\Viewer for a long time - the app actually lives at Playground\Apps\Viewer - +# so the clear-on-workflow-start below was sweeping an empty folder while real previews +# accumulated untouched in the served one. First existing candidate wins, so moving the +# app again does not silently resurrect that. +_PREVIEW_CANDIDATES = [ + os.environ.get("RM_PREVIEW_DIR", ""), + r"C:\Users\rober\Playground\Apps\Viewer\public\previews", + r"C:\Users\rober\Playground\Viewer\public\previews", +] + + +def _resolve_preview_dir(): + for candidate in _PREVIEW_CANDIDATES: + if candidate and os.path.isdir(candidate): + return candidate + # Nothing exists yet: prefer the current app location rather than the legacy one. + return _PREVIEW_CANDIDATES[1] + + +PREVIEW_DIR = _resolve_preview_dir() def ensure_preview_dir():