Skip to content

fix(octop): guard Path.stat() with OSError in backup store (three call sites) - #2667

Closed
TrueFurina wants to merge 1 commit into
TencentCloud:mainfrom
TrueFurina:r78-backup-store-stat-guard
Closed

TrueFurina wants to merge 1 commit into
TencentCloud:mainfrom
TrueFurina:r78-backup-store-stat-guard

Conversation

@TrueFurina

Copy link
Copy Markdown

Summary

Wrap three bare Path.stat() calls in infra/backup/store.py with try/except OSError. One file, one commit.

Changes

Call site Location On OSError
stat().st_birthtime resolve_backup_created_at() Default to birth=None, fall through to mtime
p.stat().st_mtime + iterdir() list_backup_files() sort key Return empty backup list
stat().st_mtime/.st_size backup_file_info() Raise OctopError(NOT_FOUND) with unreadable message

Context

All three paths gate stat() with is_file()/is_dir() checks. On Windows these only verify directory entry existence, not read permission. ACL restrictions, antivirus file locks, or transient handles can all raise PermissionError during stat() — the exact same failure mode fixed for iterdir(), glob(), and read_text()/read_bytes() in preceding rounds.

…tes)

Three bare Path.stat() calls in the backup store module. On Windows, stat() can raise PermissionError from ACL restrictions or antivirus file locks even after is_file()/is_dir() gates pass. All three are on user-data paths under the backups directory.

1. resolve_backup_created_at(): stat().st_birthtime fallback after filename stamp. On OSError default birth=None and fall through to mtime.

2. list_backup_files(): sorted key function p.stat().st_mtime plus the iterdir() call. Wrap both in try/except OSError and return empty list.

3. backup_file_info(): stat() after is_file() check. On OSError raise OctopError(NOT_FOUND) with 'unreadable' message.
@jubaoliang jubaoliang closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants