Only migrate if current version is higher (#349)
This commit is contained in:
parent
a3cfde1950
commit
2d046181b0
|
@ -30,11 +30,11 @@ public final class DefaultUpgradeManagerStrategy: UpgradeManagerStrategy {
|
||||||
public init() {
|
public init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public func doMigrateStore(_ store: KeyValueStore, lastVersion: String?) {
|
public func doMigrate(store: KeyValueStore, lastVersion: String?) {
|
||||||
if let lastVersion {
|
guard let lastVersion else {
|
||||||
pp_log.debug("Upgrade from \(lastVersion)")
|
|
||||||
} else {
|
|
||||||
pp_log.debug("Fresh install")
|
pp_log.debug("Fresh install")
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
pp_log.debug("Upgrade from \(lastVersion)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,11 @@ public final class UpgradeManager: ObservableObject {
|
||||||
self.strategy = strategy
|
self.strategy = strategy
|
||||||
}
|
}
|
||||||
|
|
||||||
public func doMigrations(_ profileManager: ProfileManager) {
|
public func doMigrations(toVersion currentVersion: String, profileManager: ProfileManager) {
|
||||||
strategy.doMigrateStore(store, lastVersion: lastVersion)
|
if let lastVersion, currentVersion > lastVersion {
|
||||||
lastVersion = Constants.Global.appVersionNumber
|
strategy.doMigrate(store: store, lastVersion: lastVersion)
|
||||||
|
}
|
||||||
|
lastVersion = currentVersion
|
||||||
isDoingMigrations = false
|
isDoingMigrations = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,5 +27,5 @@ import Foundation
|
||||||
import PassepartoutCore
|
import PassepartoutCore
|
||||||
|
|
||||||
public protocol UpgradeManagerStrategy {
|
public protocol UpgradeManagerStrategy {
|
||||||
func doMigrateStore(_ store: KeyValueStore, lastVersion: String?)
|
func doMigrate(store: KeyValueStore, lastVersion: String?)
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,10 @@ private extension OrganizerView.ProfilesList {
|
||||||
|
|
||||||
func performMigrationsIfNeeded() {
|
func performMigrationsIfNeeded() {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
UpgradeManager.shared.doMigrations(profileManager)
|
UpgradeManager.shared.doMigrations(
|
||||||
|
toVersion: Constants.Global.appVersionNumber,
|
||||||
|
profileManager: profileManager
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue