Enhanced File Deletion Logic with Structured Error Handling and Detailed Logging #7085
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.
Task/Issue URL
N/A (Internal enhancement – improves file deletion reliability and logging)
Description
This PR enhances the AndroidFileDeleter implementation by adding structured error handling, detailed logging, and improved coroutine usage.
It ensures better visibility, safety, and maintainability for all file deletion operations across the app.
Key changes:
1.Added runCatching blocks for structured exception handling.
2.Introduced per-file deletion success/failure tracking.
3.Enhanced log messages with INFO/ERROR priorities.
4.Implemented summary logs showing number of successful deletions.
5.Ensured all operations run in dispatchers.io() context to avoid blocking the main thread.
6.Improved readability with clear filtering and early returns.
Steps to test this PR
Feature: Enhanced File Deletion Logging
Trigger file deletion in a directory (e.g., cache or temp folder).
Verify that deleted files are logged with success messages.
Verify that failed deletions log detailed error messages without crashing.
Check log summary shows accurate count of deleted vs attempted files.
Confirm that excluded files remain untouched.
UI changes
Before
(No visible UI changes — internal logic update)
After
(No visible UI changes — improved backend behavior)