From 75b08df0a4ba959b07dc3996c8a9c1ebefb219af Mon Sep 17 00:00:00 2001 From: Nika Siradze Date: Thu, 19 Nov 2026 12:18:07 +0400 Subject: [PATCH 1/2] Render thumbnails when the output folder is a relative path The screenshot tools run with the runtime root as their working directory, so a relative --output such as -o clips resolved against that folder and every thumbnail failed with ENOENT. Make the output path absolute before handing it over. --- backend/services/thumbnail_html.py | 3 ++- tests/test_thumbnail_html.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/backend/services/thumbnail_html.py b/backend/services/thumbnail_html.py index cc79174..49de49b 100644 --- a/backend/services/thumbnail_html.py +++ b/backend/services/thumbnail_html.py @@ -794,7 +794,8 @@ def generate_thumbnail( tmp_html.write(html) tmp_html.close() - os.makedirs(os.path.dirname(output_path) or ".", exist_ok=True) + output_path = os.path.abspath(output_path) + os.makedirs(os.path.dirname(output_path), exist_ok=True) try: w = cfg["width"] diff --git a/tests/test_thumbnail_html.py b/tests/test_thumbnail_html.py index 58265c5..a03525c 100644 --- a/tests/test_thumbnail_html.py +++ b/tests/test_thumbnail_html.py @@ -1,6 +1,8 @@ import os +import shutil import subprocess import sys +import tempfile import unittest from unittest import mock @@ -128,6 +130,26 @@ def test_generate_thumbnail_prefers_remotion_before_playwright(self): self.assertEqual(run_mock.call_args_list[0].args[0], ["node", "script", "a", "b", "1080", "1920", "1500"]) + def test_a_relative_output_path_reaches_the_screenshot_tool_as_absolute(self): + tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, tmp, True) + here = os.getcwd() + os.chdir(tmp) + self.addCleanup(os.chdir, here) + with mock.patch.object(th, "_build_html", return_value=""), \ + mock.patch.object(th, "_remotion_screenshot_script_path", return_value=__file__), \ + mock.patch.object(th, "_playwright_cli_candidates", return_value=[]), \ + mock.patch.object(th.os.path, "exists", return_value=True), \ + mock.patch.object(th.shutil, "which", return_value="/usr/bin/node"), \ + mock.patch.object(th.subprocess, "run", return_value=subprocess.CompletedProcess( + args=["node"], returncode=0, stdout="", stderr="")) as run_mock: + output = th.generate_thumbnail("line1", "line2", os.path.join("clips", "thumb.png")) + + expected = os.path.join(os.path.realpath(tmp), "clips", "thumb.png") + self.assertEqual(os.path.realpath(output), expected) + call = run_mock.call_args + self.assertEqual(os.path.realpath(os.path.join(call.kwargs["cwd"], call.args[0][3])), expected) + class LayerTests(unittest.TestCase): """ The parts a show adds itself, over a template whose anatomy is fixed. From 0a84ead63fe90a0b43d4071e56e7784e59908da7 Mon Sep 17 00:00:00 2001 From: Nika Siradze Date: Thu, 19 Nov 2026 12:23:11 +0400 Subject: [PATCH 2/2] Compare the thumbnail path in its native absolute form abspath turns /tmp/thumb.png into C:\tmp\thumb.png on Windows, so the existing test compared against a string the code no longer returns there. --- tests/test_thumbnail_html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_thumbnail_html.py b/tests/test_thumbnail_html.py index a03525c..143bb38 100644 --- a/tests/test_thumbnail_html.py +++ b/tests/test_thumbnail_html.py @@ -126,7 +126,7 @@ def test_generate_thumbnail_prefers_remotion_before_playwright(self): ]) as run_mock: output = th.generate_thumbnail("line1", "line2", "/tmp/thumb.png") - self.assertEqual(output, "/tmp/thumb.png") + self.assertEqual(output, os.path.abspath("/tmp/thumb.png")) self.assertEqual(run_mock.call_args_list[0].args[0], ["node", "script", "a", "b", "1080", "1920", "1500"])