Fix recycle bin filling up storage when deleting multiple items #2600
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.
The current implementation of
BaseSimpleActivity.movePathsInRecycleBin
moves all the selections into the recycle bin, and then deletes them all at once.Say the selected items have a total size of 5GB and available space on the device is 2GB, if all are moved to recycle bin at once, storage will be filled up and the app is going to crash.
Hence, I made it so that the app deletes the moved items whenever the remaining space is not enough...
Example
Current implementation
5GB size -> copy 5GB recycle bin -> crash (5GB > 1GB)
delete the old 5GB from storage❌ crash
Suggested implementation
5GB size -> copy 2GB recycle bin -> delete the old 2GB from storage
3GB size -> copy 2GB recycle bin -> delete the old 2GB from storage
1GB size -> copy 1GB recycle bin -> delete the old 1GB from storage
✔ success
Affected issues