mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
clear core data when switch env
This commit is contained in:
parent
987336f438
commit
9b9191b6b1
1 changed files with 15 additions and 11 deletions
|
|
@ -59,9 +59,8 @@ public final class DataService: ObservableObject {
|
|||
await networker.hasConnectionAndValidToken()
|
||||
}
|
||||
|
||||
private func resetCoreData() {
|
||||
let storeContainer =
|
||||
persistentContainer.persistentStoreCoordinator
|
||||
private func clearCoreData() {
|
||||
let storeContainer = persistentContainer.persistentStoreCoordinator
|
||||
|
||||
do {
|
||||
for store in storeContainer.persistentStores {
|
||||
|
|
@ -71,18 +70,23 @@ public final class DataService: ObservableObject {
|
|||
options: nil
|
||||
)
|
||||
}
|
||||
persistentContainer = PersistentContainer.make()
|
||||
persistentContainer.loadPersistentStores { _, error in
|
||||
if let error = error {
|
||||
fatalError("Core Data store failed to load with error: \(error)")
|
||||
}
|
||||
}
|
||||
backgroundContext = persistentContainer.newBackgroundContext()
|
||||
} catch {
|
||||
logger.debug("Failed to reset core data stores")
|
||||
logger.debug("Failed to clear core data stores")
|
||||
}
|
||||
}
|
||||
|
||||
private func resetCoreData() {
|
||||
clearCoreData()
|
||||
|
||||
persistentContainer = PersistentContainer.make()
|
||||
persistentContainer.loadPersistentStores { _, error in
|
||||
if let error = error {
|
||||
fatalError("Core Data store failed to load with error: \(error)")
|
||||
}
|
||||
}
|
||||
backgroundContext = persistentContainer.newBackgroundContext()
|
||||
}
|
||||
|
||||
private func isFirstTimeRunningNewAppVersion() -> Bool {
|
||||
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")
|
||||
guard let appVersion = appVersion as? String else { return false }
|
||||
|
|
|
|||
Loading…
Reference in a new issue