diff --git a/internal/api/client.go b/internal/api/client.go index 06a9b5a..9b49666 100644 --- a/internal/api/client.go +++ b/internal/api/client.go @@ -226,13 +226,15 @@ type ClientCreationOpts struct { // Required. The password for this account. Password string - // Optional. If true, persistent storage will be used for the same user|device ID. - PersistentStorage bool // Required for rust clients. The URL of the sliding sync proxy. SlidingSyncURL string // Optional. Set this to login with this device ID. DeviceID string + // A hint to the client implementation that persistent storage is required. Clients may ignore + // this flag and always use persistence. + PersistentStorage bool + // Rust only. If set, enables the cross process refresh lock on the FFI client with the process name provided. EnableCrossProcessRefreshLockProcessName string // Rust only. If set with EnableCrossProcessRefreshLockProcessName=ProcessNameNSE, the client will be seeded diff --git a/internal/api/rust/rust.go b/internal/api/rust/rust.go index c62114d..e364c15 100644 --- a/internal/api/rust/rust.go +++ b/internal/api/rust/rust.go @@ -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{