Improve Error Handling for os.remove() in Autosave Mechanism (app.py)
wontfix
In the current version of Flowblade (2.24, as of December 2025 release), there are issues with error handling for `os.remove()` calls in `flowblade-trunk/Flowblade/src/app.py` related to autosave file management.
These can lead to unhandled exceptions or overly broad exception catching, potentially causing silent failures during autosave recovery or application shutdown.
## Specific problems:
• Line 743: After loading an autosave file – No error handling for os.remove(loaded_autosave_file). Fails if file not found or permissions issue.
• Line 839: In autosave recovery callback (else branch) – No error handling for os.remove(autosave_file).
• Line 1174: During app shutdown – Uses a bare except clause for os.remove(...), which is too broad and can mask unrelated errors.
This affects reliability, especially on systems with file permission variations or in edge cases like rapid crashes/recoveries.
## Impact
This affects reliability on systems with:
- File permission variations
- Edge cases like rapid crashes/recoveries
- Strict filesystem restrictions
## Proposed Solution
Implement a reusable helper function `safe_remove_file()` that:
- Handles specific exceptions (`FileNotFoundError`, `PermissionError`, `OSError`)
- Provides proper logging for debugging
- Returns boolean status for caller error recovery
- Follows DRY principle
## Reference Implementation
A working implementation is available in this fork:
- **Repository:** https://github.com/Kvnbbg/flowblade
- **Merged Branch:** `improve/robust-file-deletion-error-handling`
I’ve created a fork at https://github.com/Kvnbbg/flowblade with a branch implementing a reusable helper function safe_remove_file to handle specific exceptions (FileNotFoundError, PermissionError, OSError) with optional logging. This makes the code more robust and consistent without altering core logic.
## Key changes in the fork:
• Added safe_remove_file after imports.
• Replaced raw os.remove() at the affected lines.
• For line 839: Conditional start_autosave() on success.
• For line 1174: Specific logging matching the original.
A detailed patch is available in my fork (or I can attach it here if needed). Happy to submit a PR if this issue is approved!
## Steps to Reproduce Issues:
1. Simulate a file deletion failure (e.g., make autosave file read-only).
2. Trigger autosave recovery or app shutdown.
3. Observe unhandled errors or broad catching
关闭于 2026-01-07 1 条评论