Fix exceptions thrown on already migrated JSON

Also remove deprecated tunnel configuration keys.
This commit is contained in:
Davide De Rosa 2018-10-26 10:49:37 +02:00
parent 4344eb9779
commit 8f29f79168
1 changed files with 6 additions and 1 deletions

View File

@ -58,7 +58,8 @@ extension ConnectionService {
static func migrateToWrappedSessionConfiguration(_ json: inout [String: Any]) throws { static func migrateToWrappedSessionConfiguration(_ json: inout [String: Any]) throws {
guard let profiles = json["profiles"] as? [[String: Any]] else { guard let profiles = json["profiles"] as? [[String: Any]] else {
throw ApplicationError.migration // migrated
return
} }
var newProfiles: [[String: Any]] = [] var newProfiles: [[String: Any]] = []
for var container in profiles { for var container in profiles {
@ -83,6 +84,7 @@ extension ConnectionService {
static func migrateToBaseConfiguration(_ json: inout [String: Any]) throws { static func migrateToBaseConfiguration(_ json: inout [String: Any]) throws {
guard var baseConfiguration = json["tunnelConfiguration"] as? [String: Any] else { guard var baseConfiguration = json["tunnelConfiguration"] as? [String: Any] else {
// migrated
return return
} }
migrateSessionConfiguration(in: &baseConfiguration) migrateSessionConfiguration(in: &baseConfiguration)
@ -124,5 +126,8 @@ extension ConnectionService {
sessionConfiguration["renegotiatesAfter"] = value sessionConfiguration["renegotiatesAfter"] = value
} }
map["sessionConfiguration"] = sessionConfiguration map["sessionConfiguration"] = sessionConfiguration
map.removeValue(forKey: "debugLogKey")
map.removeValue(forKey: "lastErrorKey")
} }
} }