Skip to content

Feature/clean thumbnails avatars#85

Open
zerox80 wants to merge 4 commits intoopencloud-eu:mainfrom
zerox80:feature/clean-thumbnails-avatars
Open

Feature/clean thumbnails avatars#85
zerox80 wants to merge 4 commits intoopencloud-eu:mainfrom
zerox80:feature/clean-thumbnails-avatars

Conversation

@zerox80
Copy link
Contributor

@zerox80 zerox80 commented Jan 19, 2026

Thumbnail Cache Refactoring and Avatar Fixes

Summary

This pull request refactors the thumbnail caching mechanism to improve performance and stability, and includes critical fixes for user avatar loading. The legacy ThumbnailsCacheManager has been replaced by an optimized ThumbnailsRequester implementation, and several thread safety issues have been resolved.

Technical Details

Thumbnail Caching

  • Refactoring: Completely removed ThumbnailsCacheManager and DiskLruImageCache in favor of a modern, streamlined approach within ThumbnailsRequester.
  • Thread Safety: Addressed race conditions in ThumbnailsRequester when initializing the shared disk and memory caches. Access to these caches is now properly synchronized.
  • Optimization: Adjusted thumbnail sizing logic to prevent memory waste and improve loading times.
  • Dead Code Removal: Cleaned up unused legacy code and resources related to the old caching system.

Avatar Loading

  • Graph API Integration: Updated the user avatar loading logic to utilize the Graph API endpoint, ensuring reliable retrieval of user profile images.
  • Cache Control: Fixed issues with avatar cache invalidation and loading control to ensure users always see the correct profile picture.
  • Bug Fixes: Resolved specific crashes and loading failures related to avatar requests in various parts of the UI (Drawer, Toolbar, Upload List).

Other Changes

  • Code Quality: Resolved extensive Detekt issues, including formatting and spacing violations.
  • Stability: Fixed potential crashes caused by incorrect context usage or missing null checks in the thumbnail generation flow.

Impact

These changes significantly reduce the maintenance burden by removing complex legacy caching code and provide a smoother user experience with faster and more reliable thumbnail and avatar loading.

Testing

  • Verified that file thumbnails load correctly in the file list and grid view.
  • Verified that user avatars appear correctly in the navigation drawer and toolbar.
  • Confirmed that removing the legacy cache classes does not introduce regressions in image loading.

@zerox80 zerox80 force-pushed the feature/clean-thumbnails-avatars branch 2 times, most recently from 6f322b4 to 72d55fa Compare January 20, 2026 08:05

private const val SPACE_SPECIAL_PREVIEW_URI = "%s?scalingup=0&a=1&x=%d&y=%d&c=%s&preview=1"
private const val FILE_PREVIEW_URI = "%s%s?x=%d&y=%d&c=%s&preview=1&id=%s"
private const val FILE_PREVIEW_URI = "%s/remote.php/webdav%s?x=%d&y=%d&c=%s&preview=1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this looks good, OpenCloud is not PHP anymore.

@guruz
Copy link
Contributor

guruz commented Feb 10, 2026

Thumbnail Caching

I haven't really looked at the code yet. Where is stuff cached? From the names it seems it was Disk(Lru) before, what is it now?

@guruz
Copy link
Contributor

guruz commented Feb 24, 2026

FYI I'm looking / testing this PR now. @zerox80

@zerox80
Copy link
Contributor Author

zerox80 commented Feb 25, 2026

Hi, ill take a look now, was busy sorry

@zerox80
Copy link
Contributor Author

zerox80 commented Feb 25, 2026

re-test please @guruz

@zerox80
Copy link
Contributor Author

zerox80 commented Feb 25, 2026

Thumbnail Caching

I haven't really looked at the code yet. Where is stuff cached? From the names it seems it was Disk(Lru) before, what is it now?

We completely moved away from the old manual DiskLruCache handling and now rely on Coil's built-in caching mechanism, which is much more efficient and modern.

It uses a two-tier caching strategy (both Memory and Disk cache), which is configured centrally in the ThumbnailsRequester.kt

Disk Cache: We use Coil's DiskCache.Builder() to store thumbnails in the app's cache directory (thumbnails_coil_cache). It is explicitly limited to 100MB to ensure it doesn't inflate the app storage endlessly. (Location: appContext.cacheDir.resolve("thumbnails_coil_cache"))

Memory Cache: We use Coil's MemoryCache.Builder() configured to use up to 25% of the available application memory (maxSizePercent(0.25)). This drastically improves scrolling performance in lists/grids because decoded images are kept directly in memory.

Both caches are shared as Singletons (sharedDiskCache and sharedMemoryCache) and passed to the ImageLoader instance, so the caching rules apply globally to all thumbnail requests handled by Coil

This commit acts as a squash of the thumbnail cache refactoring and avatar fixes.

See PR description for full details.
- Update FILE_PREVIEW_URI to use direct native /webdav path.
- Use Graph API explicitly for fetching Avatar image, dropping the /index.php/avatar hack & interceptor fallbacks.
@zerox80 zerox80 force-pushed the feature/clean-thumbnails-avatars branch from a5268f3 to a5e37bc Compare February 25, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants