From caab7fa9bc52022f43fa4e6e93c470a5fea5d8e1 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 5 Apr 2019 19:37:18 +0200 Subject: [PATCH] Fall back to default infrastructure preset Fixes #57 --- Passepartout/Sources/Model/ConnectionService.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Passepartout/Sources/Model/ConnectionService.swift b/Passepartout/Sources/Model/ConnectionService.swift index 1f4e1bf1..291296a3 100644 --- a/Passepartout/Sources/Model/ConnectionService.swift +++ b/Passepartout/Sources/Model/ConnectionService.swift @@ -263,7 +263,14 @@ public class ConnectionService: Codable { let data = try profileData(key) switch key.context { case .provider: - profile = try decoder.decode(ProviderConnectionProfile.self, from: data) + let providerProfile = try decoder.decode(ProviderConnectionProfile.self, from: data) + + // fix renamed presets, fall back to default + if providerProfile.preset == nil { + providerProfile.presetId = providerProfile.infrastructure.defaults.preset + } + + profile = providerProfile case .host: let hostProfile = try decoder.decode(HostConnectionProfile.self, from: data)