mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 09:38:39 +00:00
fix(iOS): preserve legacy data when Keychain write fails during migration
(cherry picked from commit ea47df92fa)
This commit is contained in:
@@ -223,11 +223,12 @@ enum GatewaySettingsStore {
|
|||||||
defaults.removeObject(forKey: self.lastGatewayStableIDDefaultsKey)
|
defaults.removeObject(forKey: self.lastGatewayStableIDDefaultsKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func saveLastGatewayConnectionData(_ payload: LastGatewayConnectionData) {
|
@discardableResult
|
||||||
|
private static func saveLastGatewayConnectionData(_ payload: LastGatewayConnectionData) -> Bool {
|
||||||
guard let data = try? JSONEncoder().encode(payload),
|
guard let data = try? JSONEncoder().encode(payload),
|
||||||
let json = String(data: data, encoding: .utf8)
|
let json = String(data: data, encoding: .utf8)
|
||||||
else { return }
|
else { return false }
|
||||||
_ = KeychainStore.saveString(
|
return KeychainStore.saveString(
|
||||||
json, service: self.gatewayService, account: self.lastGatewayConnectionAccount)
|
json, service: self.gatewayService, account: self.lastGatewayConnectionAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +260,7 @@ enum GatewaySettingsStore {
|
|||||||
kind: kind, stableID: stableID, useTLS: useTLS,
|
kind: kind, stableID: stableID, useTLS: useTLS,
|
||||||
host: kind == .manual ? host : nil,
|
host: kind == .manual ? host : nil,
|
||||||
port: kind == .manual ? port : nil)
|
port: kind == .manual ? port : nil)
|
||||||
self.saveLastGatewayConnectionData(payload)
|
guard self.saveLastGatewayConnectionData(payload) else { return }
|
||||||
self.removeLastGatewayDefaults(defaults)
|
self.removeLastGatewayDefaults(defaults)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public enum GatewayTLSStore {
|
|||||||
!existing.isEmpty
|
!existing.isEmpty
|
||||||
else { return }
|
else { return }
|
||||||
if self.keychainLoad(account: stableID) == nil {
|
if self.keychainLoad(account: stableID) == nil {
|
||||||
self.keychainSave(existing, account: stableID)
|
guard self.keychainSave(existing, account: stableID) else { return }
|
||||||
}
|
}
|
||||||
defaults.removeObject(forKey: legacyKey)
|
defaults.removeObject(forKey: legacyKey)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user