Skip to content

Feature/added method to get current disk cache size#270

Open
kothawade29 wants to merge 3 commits into
dream-horizon-org:mainfrom
kothawade29:feature/added-method-to-get-current-disk-cache-size
Open

Feature/added method to get current disk cache size#270
kothawade29 wants to merge 3 commits into
dream-horizon-org:mainfrom
kothawade29:feature/added-method-to-get-current-disk-cache-size

Conversation

@kothawade29
Copy link
Copy Markdown

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)

@github-actions
Copy link
Copy Markdown

🚀 Thanks for your first Pull Request!
Your contribution is greatly appreciated, and a maintainer will review it soon.
Meanwhile, feel free to check out other issues or share your thoughts on the project.
We’re excited to have you on board! 🎉

@JatinDream11
Copy link
Copy Markdown
Contributor

Please resolve the conflicts and add testing example in ReactNativeFastImageExample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants