-
Notifications
You must be signed in to change notification settings - Fork 259
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
media: cache media's content after uploading it #4149
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4149 +/- ##
==========================================
- Coverage 84.84% 84.83% -0.01%
==========================================
Files 269 269
Lines 28793 28824 +31
==========================================
+ Hits 24429 24454 +25
- Misses 4364 4370 +6 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks.
I'm hesitant to merge this, because I think that for the local echo for media upload, we'll need a strategy where we'll first store the media in the cache, with a temporary MXC url, and then after it's been uploaded, replace the underlying temporary MXC url with the one returned from the server. We could use the same strategy here to avoid cloning the data we want to store in the cache, and that will be aligned with the local echo feature. |
19accca
to
722dd22
Compare
Re-requesting review because of non-trivial changes: I made it so that one can take the bytes by reference instead of by ownership, which required tweaking the |
We've discussed this in the Rust chapter, and we're going to keep it super simple (so, remove the last commit), and add caching of thumbnails as is. Drafting. |
Changelog: Uploaded medias can now be cached in multiple attachment-related methods like `Room::send_attachment`.
22c9590
to
daa05ea
Compare
We can't know which key is going to be used precisely for the thumbnail, so assume non-animated cropped same-size thumbnail media request. Changelog: when `SendAttachment::store_in_cache()` is set, the thumbnail is also cached with a sensible default media request (not animated, cropped, same dimensions as the uploaded thumbnail).
daa05ea
to
3b9fc3c
Compare
Done. Would still appreciate a re-review, since the thumbnail is now being cached too :) Thanks in advance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks
This adds an optional way to cache a media's content after uploading it successfully. In a followup PR, I'll also add caching of the thumbnail, in a slightly smarter way than we do right now (always return a cache hit independently of the requested thumbnail features).
Part of #1732.