Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for atomically accessing an image request's disk cache entry #2630

Open
saket opened this issue Nov 2, 2024 · 2 comments
Open

API for atomically accessing an image request's disk cache entry #2630

saket opened this issue Nov 2, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@saket
Copy link

saket commented Nov 2, 2024

image

Is your feature request related to a problem? Please describe.
Telephoto uses coil's disk cache for streaming large images directly from the disk. This is working well for most users, but some users are reporting crashes where coil is returning a null cache entry, possibly because the cache entry was either cleared or opened somewhere else before telephoto could access it.

Describe the solution you'd like

an atomic API that writes the image data to disk then immediately opens a source for the file. That way we avoid the race condition between writing the image data and calling openSnapshot

Additional context
saket/telephoto#106 (comment)

@revonateB0T
Copy link
Contributor

Isn't there already a commitAndOpenSnapshot?

override fun commitAndOpenSnapshot() = editor.commitAndGet()?.let(::RealSnapshot)

@colinrtwhite
Copy link
Member

@revonateB0T That API's only useful if you're also writing the data. Saket's looking for an API that will do URL -> DiskCache.Snapshot. The current way of URL -> disk cache key -> DiskCache.Snapshot allows some cases where disk cache key -> DiskCache.Snapshot will return null (race conditions around simultaneous read/write, cache getting cleared).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants