matrix-org / matrix-rust-sdk

Matrix Client-Server SDK for Rust
Apache License 2.0
1.27k stars 254 forks source link

ffi: Return the state store directory name back after sanitizing #3098

Open bmarty opened 9 months ago

bmarty commented 9 months ago

When the application creates a session, the SDK create asubfolder with a "sanitized" name:

https://github.com/matrix-org/matrix-rust-sdk/blob/916bf69e5c7630d63ffc6be9ceb1316efbec771f/bindings/matrix-sdk-ffi/src/client_builder.rs#L175

The application needs to know the folder name for instance to compute its size, or to fully delete it on session log out.

Currently the app is computing it using a simple replacement ":" -> "_", but that may not be enough for some userIds.

So the SDK should provide the created folder name, and a solution could be to add a new Client.getFolderName API.

bnjbvr commented 9 months ago

Thanks for opening an issue. Probably should wait for this code to move to the authentication service in the SDK.

bnjbvr commented 9 months ago

@bmarty if the SDK provided you with the database name (which would be a randomly-generated UUID), could you map it internally (e.g. in a separate JSON file) to the user id? We could feed two birds with one seed, and avoid the double-client situation at login, thanks to that. (I've chatted about it with EXI folks and they seem to be ok with it.)

jmartinesp commented 9 months ago

@bmarty if the SDK provided you with the database name (which would be a randomly-generated UUID), could you map it internally (e.g. in a separate JSON file) to the user id? We could feed two birds with one seed, and avoid the double-client situation at login, thanks to that. (I've chatted about it with EXI folks and they seem to be ok with it.)

I think we could just add it to the session data we already store as another field.

bmarty commented 9 months ago

Yes, OK, and the randomly-generated UUID will be used as the folder name as well (so there is a sort of behavior break?)?

bnjbvr commented 9 months ago

Yes, OK, and the randomly-generated UUID will be used as the folder name as well (so there is a sort of behavior break?)?

Yes to your first question, yes and no to the second in parenthesis. It's only a behavior break when we didn't have any folder name injected in the login process, aka the user is logging in for the first time.

For re-logins, the client could still be fed with the folder name returned previously (so either based on the user id for current users, or the UUID returned by the client in the future).