@@ -108,35 +108,45 @@ open class NextcloudKit {
108108 nkCommonInstance. nksessions. append ( nkSession)
109109 }
110110
111+ /// Updates an existing `NKSession` stored in the synchronized array.
112+ ///
113+ /// This method looks up the session by its `account` identifier, applies any non-nil
114+ /// parameters to mutate the session, and then replaces the stored value using
115+ /// `SynchronizedNKSessionArray.replace(account:with:)`.
116+ ///
117+ /// - Parameters:
118+ /// - account: The account identifier used to locate the session to update.
119+ /// - urlBase: An optional new base URL for the session.
120+ /// - user: An optional new username for the session.
121+ /// - userId: An optional new user identifier for the session.
122+ /// - password: An optional new password or token for the session.
123+ /// - userAgent: An optional new User-Agent string for the session.
111124 public func updateSession( account: String ,
112125 urlBase: String ? = nil ,
113126 user: String ? = nil ,
114127 userId: String ? = nil ,
115128 password: String ? = nil ,
116- userAgent: String ? = nil ,
117- replaceWithAccount: String ? = nil ) {
118- guard var nkSession = nkCommonInstance. nksessions. session ( forAccount: account) else {
129+ userAgent: String ? = nil ) {
130+ guard var newSession = nkCommonInstance. nksessions. session ( forAccount: account) else {
119131 return
120132 }
121133
122134 if let urlBase {
123- nkSession . urlBase = urlBase
135+ newSession . urlBase = urlBase
124136 }
125137 if let user {
126- nkSession . user = user
138+ newSession . user = user
127139 }
128140 if let userId {
129- nkSession . userId = userId
141+ newSession . userId = userId
130142 }
131143 if let password {
132- nkSession . password = password
144+ newSession . password = password
133145 }
134146 if let userAgent {
135- nkSession. userAgent = userAgent
136- }
137- if let replaceWithAccount {
138- nkSession. account = replaceWithAccount
147+ newSession. userAgent = userAgent
139148 }
149+ nkCommonInstance. nksessions. replace ( account: account, with: newSession)
140150 }
141151
142152 public func deleteCookieStorageForAccount( _ account: String ) {
0 commit comments