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

rust: always use persistence in clients #115

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions internal/api/rust/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,21 @@ func NewRustClient(t ct.TestLike, opts api.ClientCreationOpts) (api.Client, erro
clientSessionDelegate = NewMemoryClientSessionDelegate()
ab = ab.EnableCrossProcessRefreshLock(opts.EnableCrossProcessRefreshLockProcessName, clientSessionDelegate)
}
var username string
if opts.PersistentStorage {
// @alice:hs1, FOOBAR => alice_hs1_FOOBAR
username = strings.Replace(opts.UserID[1:], ":", "_", -1) + "_" + opts.DeviceID
ab = ab.SessionPath("rust_storage/" + username).Username(username)
}
// @alice:hs1, FOOBAR => alice_hs1_FOOBAR
username := strings.Replace(opts.UserID[1:], ":", "_", -1) + "_" + opts.DeviceID
ab = ab.SessionPath("rust_storage/" + username).Username(username)
client, err := ab.Build()
if err != nil {
return nil, fmt.Errorf("ClientBuilder.Build failed: %s", err)
}
c := &RustClient{
userID: opts.UserID,
FFIClient: client,
roomsListener: NewRoomsListener(),
rooms: make(map[string]*RustRoomInfo),
roomsMu: &sync.RWMutex{},
opts: opts,
}
if opts.PersistentStorage {
c.persistentStoragePath = "./rust_storage/" + username
userID: opts.UserID,
FFIClient: client,
roomsListener: NewRoomsListener(),
rooms: make(map[string]*RustRoomInfo),
roomsMu: &sync.RWMutex{},
opts: opts,
persistentStoragePath: "./rust_storage/" + username,
}
if opts.AccessToken != "" { // restore the session
session := matrix_sdk_ffi.Session{
Expand Down
Loading