os.path.getsize
The file-size check that keeps broken runs from passing
- path_in
- size
Here's a workflow smell I've seen too many times: a video or batch of images "finishes," a downstream step opens the output, and it's a 0-byte file or a half-written one. The save didn't fail loudly - it just quietly produced nothing useful. os.path.getsize is the cheapest guard against that, because it gives you the byte count of any file on disk as a plain INT you can branch on.
It's part of the ovum/path/os.path family in comfy-ovum, sfinktah's utility pack. Like its siblings it's a direct wrapper over the Python stdlib function - os.path.getsize() - so the number you get is exactly what Python would report, in bytes, no rounding, no units conversion.
How it works
The node stat's the file at execution time and returns its size as an INT (size). The path comes from:
- path (STRING, required): widget input, type it in.
- path_in (PATHLIKE,STRING, optional): link-only. A connected string or PATHLIKE (from "STRING to PATHLIKE (PurePath)") takes precedence over the widget.
Single INT output. Nothing cached, no state - re-run and you get a fresh read, which is what you want when you're polling a file mid-write.
The pattern that makes it useful
The high-value move is a sanity gate after your saver node: wire the saved file's path in, compare the size against a threshold with a compare node, and feed that boolean into an IfElse-style branch (comfy-ovum has CompareOvum/IfElseOvum in the same pack, or use any logic nodes you already have). Size below a few KB for a video that should be tens of MB? Something went wrong - skip the "open in player" step and log it instead. It also earns its keep in batch pipelines where you want to detect a specific frame count from total bytes, or confirm a model file was fully downloaded before you load it.
Installing it
Pack-wide install, once:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Or ComfyUI Manager → search "comfy-ovum" → Install → restart. No model downloads, and this node needs nothing beyond the stdlib - the pack's requirements.txt extras (pymediainfo, braceexpand, etc.) serve other nodes, not this one.
Gotchas
- The file must exist, or the node raises
FileNotFoundError- there's no try/except here, so a missing path is a hard run failure. If the file may not be there yet, gate withos.path.isfilefirst. - It's the raw byte count, not formatted. A 1.4 GB model comes back as
1503238554. If you want "1.4 GB" for a label, run the INT through a formatting node. - The read happens at execution time, so if a process is still writing the file you'll get a partial size. That's a feature if you're polling for "done" - combine with
os.path.getmtimeand require size to stop changing.
Between the two, mtime tells you when, size tells you how much. For "did my job actually produce a real file," size is the more honest question.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| path_inopt | PATHLIKE,STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| size | INT | — |