Trim the media cache to its cap instead of emptying it !31

merged merged by cmc on 2026-09-11 19:26 UTC · krz/skunky-art:fix/cache-rotation into main

Discussion

cmc

rotateCache(dir, lifetime, maxSize, now) replaces the loop body: expired files are removed, then if the remaining total exceeds max-size the oldest files are removed until it fits. Only files are touched; the directory stays, so the bind-mounted cache in the container no longer logs unlinkat and mkdir errors on every pass. Expired files no longer count toward the total. Ages use the modification time, which for write-once cache files equals the ctime the old code read through syscall.Stat_t, so the three per-platform stat*.go files are gone. SETUP.md updated.

Four tests over a temp directory with set mtimes. Lint clean for linux and freebsd targets.

Closes #36