Missing error handling for invalid lock file content
Priority: Medium Component: backup.py Type: Bug
Description
The lock file parsing in set_backups_lock() assumes the file contains a valid integer, but there's no error handling if the file is corrupted or contains non-numeric data.
Location
curateipsum/backup.py:114-115
Current Code
withopen(lock_file_path,"r")asf:pid=int(f.read())
Problem
If the lock file is corrupted or empty, int() will raise a ValueError, causing the backup to crash rather than handling the situation gracefully.
Proposed Solution
try:withopen(lock_file_path,"r")asf:pid=int(f.read().strip())except(ValueError,IOError)ase:_lg.warning("Corrupted lock file, removing and continuing: %s",e)os.unlink(lock_file_path)returnset_backups_lock(backups_dir,force)
Impact
Medium - Can cause backup process to crash if lock file is corrupted.
# Missing error handling for invalid lock file content
**Priority:** Medium
**Component:** backup.py
**Type:** Bug
## Description
The lock file parsing in `set_backups_lock()` assumes the file contains a valid integer, but there's no error handling if the file is corrupted or contains non-numeric data.
## Location
`curateipsum/backup.py:114-115`
## Current Code
```python
with open(lock_file_path, "r") as f:
pid = int(f.read())
```
## Problem
If the lock file is corrupted or empty, `int()` will raise a `ValueError`, causing the backup to crash rather than handling the situation gracefully.
## Proposed Solution
```python
try:
with open(lock_file_path, "r") as f:
pid = int(f.read().strip())
except (ValueError, IOError) as e:
_lg.warning("Corrupted lock file, removing and continuing: %s", e)
os.unlink(lock_file_path)
return set_backups_lock(backups_dir, force)
```
## Impact
**Medium** - Can cause backup process to crash if lock file is corrupted.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Missing error handling for invalid lock file content
Priority: Medium
Component: backup.py
Type: Bug
Description
The lock file parsing in
set_backups_lock()assumes the file contains a valid integer, but there's no error handling if the file is corrupted or contains non-numeric data.Location
curateipsum/backup.py:114-115Current Code
Problem
If the lock file is corrupted or empty,
int()will raise aValueError, causing the backup to crash rather than handling the situation gracefully.Proposed Solution
Impact
Medium - Can cause backup process to crash if lock file is corrupted.