Skip to main content

cleanup_stale_tmp_files

Function cleanup_stale_tmp_files 

pub fn cleanup_stale_tmp_files(dir: &Path)
Expand description

Remove .tmp.<pid> and .tmp.<pid>.wal artifacts in dir that are older than [STALE_TMP_AGE_SECS]. These are left behind by crashed ingest runs (the normal-path rename + drop sequence cleans them up).

Age-gated rather than PID-alive-gated: checking liveness of a foreign PID requires platform-specific syscalls and races against PID recycling. An hour-old artifact whose PID has been recycled to another codelore process is functionally equivalent to a dead-PID orphan — either way nothing legitimate is still writing to it.