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

Refactor MediaCache #405

Open
aaravlu opened this issue Feb 26, 2025 · 0 comments
Open

Refactor MediaCache #405

aaravlu opened this issue Feb 26, 2025 · 0 comments
Assignees

Comments

@aaravlu
Copy link
Contributor

aaravlu commented Feb 26, 2025

pub struct MediaCache {
    /// The actual cached data.
    cache: BTreeMap<OwnedMxcUri, MediaCacheEntryRef>,
    /// The default format to use when fetching media.
    default_format: MediaFormatConst,
    /// A channel to send updates to a particular timeline when a media request has completed.
    timeline_update_sender: Option<crossbeam_channel::Sender<TimelineUpdate>>,
}

For images in the matrix server, firstly, they are divided into two segments: the original and the thumbnail.

Then, separately, there are several versions with different resolutions under the two segments: 100x100, 200x200 ......, that is, there are many combinations.

Currently, Robrix is using a combination in the timeline: thumbnail & 400x400

But, there is a rare condition: an image is unclear enough, it would not possess a thumbnail, Ok ,we show the combination in the timeline: original & 400x400.

When user click it (the rare condition mentioned above), try_get_media_or_fetch wont fetch the combination: original & File, instead, it would find the image data (original & 400x400) via same key OwnedMxcUri in local disk, and show it, this is not what we want.


This refactoring is aimed to solve this rare problem while improving its robustness.
I shall advance #341 after this issue is fixed.

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

No branches or pull requests

1 participant