Repository navigation
fix(octop): guard Path.stat() with OSError in server log rotation and purge - #2669
Closed
TrueFurina wants to merge 1 commit into
Closed
TrueFurina wants to merge 1 commit into
TrueFurina wants to merge 1 commit into
Conversation
… purge Two bare Path.stat() calls in server.py on rotated log files. On Windows, the log directory passes is_dir() but individual entries can still raise PermissionError from antivirus locks or ACL restrictions during stat(). 1. _gzip_oldest_rotated_logs(): max() key function p.stat().st_mtime to find the oldest log to keep. On OSError bail out and skip compression (safer than crashing). 2. _purge_stale_logs(): entry.stat().st_mtime comparison with cutoff. On OSError skip that entry (continue loop). Note the subsequent entry.unlink() already uses suppress(OSError).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wrap two bare Path.stat() calls in server.py log management functions with try/except OSError. One file, one commit.
Changes
Context
Both operate on rotated log files under the server log directory. The directory already passes is_dir()/iterdir() guards from round 72, but individual log files can still be unreadable during stat() — Windows Defender/antivirus commonly locks recently-written log files briefly after rotation. The stale-log unlink() at L269 already uses suppress(OSError); this fix makes the preceding stat() equally defensive.
Pattern
Continues the Path.stat() defensive sweep. Remaining targets: postgres_storage.py, slim.py, backup.py, profile_avatar.py, manage_skills.py, skill_package_store.py.