forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceUpdateMigrator.swift
More file actions
30 lines (25 loc) · 889 Bytes
/
ServiceUpdateMigrator.swift
File metadata and controls
30 lines (25 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Foundation
import Preferences
extension UserDefaultPreferenceKeys {
struct OldMigrationVersion: UserDefaultPreferenceKey {
typealias PreferenceValueType = String
static let key = "OldMigrationVersion"
}
var oldMigrationVersion: OldMigrationVersion { .init() }
}
struct ServiceUpdateMigrator {
func migrate() {
migrate(
from: UserDefaults.shared.value(for: \.oldMigrationVersion),
to: Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion")
)
}
func migrate(from oldVersion: String, to currentVersion: String) {
guard let old = Int(oldVersion), let new = Int(currentVersion) else { return }
guard old != new else { return }
if old <= 135 {
migrateFromLowerThanOrEqualToVersion135()
}
}
}
func migrateFromLowerThanOrEqualToVersion135() {}