Log: tolerate missing rotated log files on startup

Recursive _rotate() may have already moved or unlinked the source path
by the time we try to rename it (also tolerates concurrent logrotate
runs from /etc/cron.reboot). Catch FileNotFoundError instead of
crashing bbctrl on startup.
This commit is contained in:
2026-05-03 14:03:58 +02:00
parent 0d5370a724
commit 785dafc3bc

View File

@@ -182,4 +182,11 @@ class Log(object):
if n == 16: os.unlink(fullpath)
else: self._rotate(path, nextN)
# The recursive call may have unlinked or rotated this
# path; tolerate a missing source rather than crashing
# bbctrl on startup. This also tolerates concurrent
# logrotate runs from /etc/cron.reboot.
try:
os.rename(fullpath, '%s.%d' % (path, nextN))
except FileNotFoundError:
pass