Skip to content

Commit ae22a67

Browse files
committed
handle missing gracefully
1 parent 0deb010 commit ae22a67

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/htmlcmp/compare_output_server.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def collect(a: Path, b: Path) -> list[dict]:
311311
entries.append(
312312
{
313313
"path": str(rel),
314-
"comparable": False,
314+
"comparable": True,
315315
"message": "missing in reference (A)",
316316
"result": "different",
317317
}
@@ -320,7 +320,7 @@ def collect(a: Path, b: Path) -> list[dict]:
320320
entries.append(
321321
{
322322
"path": str(rel),
323-
"comparable": False,
323+
"comparable": True,
324324
"message": "missing in monitored (B)",
325325
"result": "different",
326326
}
@@ -631,6 +631,9 @@ def image_diff(path: str):
631631
if Config.driver is None:
632632
return "Image diff not available without browser driver", 404
633633

634+
if not (Config.path_a / path).is_file() or not (Config.path_b / path).is_file():
635+
return "Image diff not available: file missing on one side", 404
636+
634637
diff, _ = html_render_diff(
635638
Config.path_a / path,
636639
Config.path_b / path,
@@ -652,6 +655,16 @@ def file(variant: str, path: str):
652655
raise ValueError("Variant must be 'a' or 'b'")
653656

654657
variant_root = Config.path_a if variant == "a" else Config.path_b
658+
659+
if not (variant_root / path).is_file():
660+
side = "reference (A)" if variant == "a" else "monitored (B)"
661+
return (
662+
"<!DOCTYPE html><html><body style='margin:0;display:flex;"
663+
"align-items:center;justify-content:center;height:100vh;"
664+
"font-family:sans-serif;color:#5f6368;background:#fafafa;'>"
665+
f"<div>file missing in {side}</div></body></html>"
666+
)
667+
655668
return send_from_directory(variant_root, path)
656669

657670

0 commit comments

Comments
 (0)