Rule R (#329): a file is a rotated copy only when it is a direct entry of
the log folder named prompt_manager.log.<n> (n >= 1, no leading zero,
compared after normcase) and a regular file that is not a symlink or a
junction. Everything else is never deleted.
- Clear (POST /logs/truncate) empties the active log and deletes only
rotated copies; a .bak, a .1.gz, any other file and every link are kept.
It runs off the event loop under one files lock and the file handler's
lock, so no rollover renames a file mid-way, and logs only afterwards.
- delete_rotated(expected) deletes exactly the reviewed copies, or nothing
when one of them changed (size, mtime_ns, inode, missing, now a link).
- The download serves only a listed regular, non-link file, opened without
following links and read off the loop; a link or folder is a 404.
- /logs/files rows gain kind; files and stats read links with lstat and
stats no longer count a link's target.
- The config update runs off the loop and swaps handlers under the files
lock.