Skip to content

feat(ffi): enable content scanner by passing an existing instance#6689

Open
jmartinesp wants to merge 3 commits into
mainfrom
feat/ffi-content-scanner
Open

feat(ffi): enable content scanner by passing an existing instance#6689
jmartinesp wants to merge 3 commits into
mainfrom
feat/ffi-content-scanner

Conversation

@jmartinesp

@jmartinesp jmartinesp commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Replace setting up the content scanner at the ClientBuilder to being able to set it on the fly when needed.

It's a lot easier for the clients to enable/disable this on the fly than having to create the client with the value ahead of time.

  • I've documented the public API changes in the appropriate changelog files (see Writing changelog entries).
  • This PR was made with the help of AI.

Signed-off-by:

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.91%. Comparing base (4bd5e81) to head (e323540).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk-contentscanner/src/lib.rs 71.42% 2 Missing ⚠️
crates/matrix-sdk/src/media.rs 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6689      +/-   ##
==========================================
+ Coverage   89.89%   89.91%   +0.01%     
==========================================
  Files         396      396              
  Lines      110412   110434      +22     
  Branches   110412   110434      +22     
==========================================
+ Hits        99258    99295      +37     
+ Misses       7370     7360      -10     
+ Partials     3784     3779       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented Jun 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing feat/ffi-content-scanner (e323540) with main (4bd5e81)

Open in CodSpeed

@jmartinesp jmartinesp marked this pull request as ready for review June 25, 2026 11:55
@jmartinesp jmartinesp requested a review from a team as a code owner June 25, 2026 11:55
@jmartinesp jmartinesp requested review from poljar and removed request for a team June 25, 2026 11:55

@poljar poljar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A couple of strange things in this PR but ok. Once fixed feel free to merge.

Comment on lines +2256 to +2258
self.inner.set_media_fetcher(media_fetcher).await;

*self.content_scanner.write().await = content_scanner;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we put this into the if branch, this avoids the need to expose DefaultMediaFetcher publicly.

Also, what's the purpose of the ContentScanner struct? Are you going to scan stuff manually on the app side?

Adding this struct could have been a nice self-contained commit or even PR for that matter, as it's not related to the hot-swapping of a media fetcher.

Comment on lines +3484 to +3485
assert!(client.content_scanner().await.is_none());
assert_eq!(client.inner.get_media_fetcher().await.to_string(), "DefaultMediaFetcher");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a strange way to do this. Usually we do this type of test with pointers to check that the objects are the same.

Can we at least use the Debug implementation so we don't add unnecessary and possibly confusing Display implementations?

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