Merge branch 'infrastructure-not-remembered'

This commit is contained in:
Davide De Rosa 2019-04-28 21:34:18 +02:00
commit c6f154ec18
2 changed files with 13 additions and 2 deletions

View File

@ -106,7 +106,12 @@ public class InfrastructureFactory {
guard let data = try? Data(contentsOf: entry) else {
continue
}
guard let infra = try? decoder.decode(Infrastructure.self, from: data) else {
let infra: Infrastructure
do {
infra = try decoder.decode(Infrastructure.self, from: data)
} catch let e {
log.warning("Unable to load infrastructure \(entry.lastPathComponent): \(e)")
log.warning("\(String(data: data, encoding: .utf8)!)")
continue
}

View File

@ -205,7 +205,13 @@ public struct InfrastructurePreset: Codable {
try container.encode(id, forKey: .id)
try container.encode(name, forKey: .name)
try container.encode(comment, forKey: .comment)
try container.encodeIfPresent(external, forKey: .external)
if let external = external {
var rawExternal: [String: String] = [:]
for entry in external {
rawExternal[entry.key.rawValue] = entry.value
}
try container.encodeIfPresent(rawExternal, forKey: .external)
}
var cfgContainer = container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration)
try cfgContainer.encode(configuration.sessionConfiguration.cipher, forKey: .cipher)