fix(ios): initial-install check within Migrations

This commit is contained in:
jahorton 2020-02-13 10:54:01 +07:00
parent e7f28d284c
commit e27ad7e2ef
2 changed files with 7 additions and 1 deletions

View file

@ -116,6 +116,11 @@ public enum Migrations {
// Detect possible version matches.
let userResources = Storage.active.userDefaults.userResources ?? []
// If there are no pre-existing resources and we need to detect a version, this is a fresh install.
if userResources.count == 0 {
return [Version.freshInstall]
}
let possibleMatches: [Version] = resourceHistory.compactMap { set in
if set.version < Version("12.0")! {
// Are all of the version's default resources present?
@ -183,7 +188,7 @@ public enum Migrations {
}
}
if lastVersion != nil {
if lastVersion != nil && lastVersion != Version.freshInstall {
// Time to deinstall the old version's resources.
// First, find the most recent version with a listed history.
let possibleHistories: [VersionResourceSet] = resourceHistory.compactMap { set in

View file

@ -14,6 +14,7 @@ public struct Version: Comparable {
public static let current = Version("13.0.65")!
// The Engine first started tracking the 'last loaded version' in 12.0.
public static let freshInstall = Version("0.0")!
public static let firstTracked = Version("12.0")!
// The Keyman App's file browser was first added in 13.0 alpha;