Feature/added method to get current disk cache size#270
Open
kothawade29 wants to merge 3 commits into
Open
Conversation
|
🚀 Thanks for your first Pull Request! |
Contributor
|
Please resolve the conflicts and add testing example in ReactNativeFastImageExample. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory.
Summary:
This PR adds a new method getDiskCacheSize() to both Android and iOS platforms for the FastImage library. The motivation is to give developers the ability to inspect how much disk space is currently used by image caching.
This feature is especially useful for apps with constrained storage budgets, for debugging cache behavior, and for implementing custom cache-clearing logic or storage warnings.
On iOS, it uses SDImageCache.diskCachePath and efficiently calculates file sizes using NSDirectoryEnumerator with preloaded metadata. On Android, it walks through the Glide cache directory recursively, summing file sizes in a background thread.
Changelog:
[ANDROID] [ADDED] - Added getDiskCacheSize() method to calculate Glide cache usage
[IOS] [ADDED] - Added getDiskCacheSize() method to calculate SDWebImage cache usage with NSURL-based traversal
Example:
Test Plan:
Test Video : https://drive.google.com/file/d/1aea-Zj8J2sHUfqQkLWe_VdzSrd3JDIHv/view?usp=drive_link
Functional Tests
TC-001: Basic Cache Size Retrieval
Objective: Verify method returns current disk cache size
Steps:
Clear disk cache
Load 3-5 images
Call getDiskCacheSize()
Expected: Returns size > 0 with valid bytes and MB values
TC-002: Empty Cache Size
Objective: Verify method handles empty cache correctly
Steps:
Clear all caches
Call getDiskCacheSize() immediately
Expected: Returns { diskCacheSizeBytes: 0, diskCacheSizeMB: 0 }
TC-003: Cross-Platform Consistency
Objective: Verify consistent behavior across platforms
Steps:
Load identical set of images on iOS and Android
Call getDiskCacheSize() on both platforms
Expected: Similar cache sizes (within reasonable variance)