fix(monitor): read a foreign file's size only when the ladder needs it (#247)

Uses PR 1's lazy file size and pins that a foreign file linked to another
prompt keeps its one link on the pair and the positive store paths.
This commit is contained in:
Vito Sansevero
2026-10-28 07:06:00 -07:00
parent 6536cee5cd
commit b1383adcc3
2 changed files with 49 additions and 5 deletions
+9 -5
View File
@@ -73,11 +73,15 @@ def decide_foreign(
in_output: bool,
lookup: Optional[Callable[[], Any]],
) -> Decision:
"""The ``MONITOR`` ladder for one foreign output."""
try:
file_size = os.path.getsize(image_path)
except OSError:
file_size = None
"""The ``MONITOR`` ladder for one foreign output (the size is read only
when the ladder needs it)."""
def file_size() -> Optional[int]:
try:
return os.path.getsize(image_path)
except OSError:
return None
return decide_file_prompt(
metadata,
file_name=os.path.basename(image_path),