FileSizeTracker

class passengersim.database.files.FileSizeTracker(paths: ~collections.abc.Iterable[~pathlib.Path], clock: ~collections.abc.Callable[[], float] = <built-in function monotonic>, stat: ~collections.abc.Callable[[~pathlib.Path], ~os.stat_result] = <function Path.stat>)[source]

Bases: object

Measure known files without opening SQLite or scanning directories.

Parameters:
paths : iterable of Path

Main database paths. WAL, shared-memory, and rollback-journal companions are included automatically when present.

clock : callable, optional

Monotonic clock used for growth measurements.

stat : callable, optional

File metadata reader, replaceable for deterministic tests.

Methods

__init__(paths[, clock, stat])

sample()

Read sizes and net growth over at most twenty seconds.

sample() → tuple[FileSize, ...][source]

Read sizes and net growth over at most twenty seconds.

Each main database and its companions share one size history. Companion creation and removal contribute to net growth without resetting it. Rates reset when the whole group disappears, the main file is replaced, or any member is unreadable, and need two observations to become defined.

Returns:

tuple of FileSize – Existing or unreadable database groups and their size/growth estimates.