matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

ffi: Return the state store directory name back after sanitizing

Open bmarty opened this issue 1 year ago • 5 comments

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.

bmarty avatar Feb 05 '24 16:02 bmarty

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

bnjbvr avatar Feb 08 '24 14:02 bnjbvr

@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.)

bnjbvr avatar Feb 12 '24 13:02 bnjbvr

@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.

jmartinesp avatar Feb 15 '24 08:02 jmartinesp

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

bmarty avatar Feb 16 '24 16:02 bmarty

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).

bnjbvr avatar Feb 20 '24 16:02 bnjbvr