Don't use core data in memory (for now)
This commit is contained in:
parent
544869c9f9
commit
6df7cf8a80
|
@ -17,7 +17,7 @@ final class SendPostIntentHandler: NSObject {
|
||||||
|
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
let coreDataStack = CoreDataStack(isInMemory: true)
|
let coreDataStack = CoreDataStack()
|
||||||
lazy var managedObjectContext = coreDataStack.persistentContainer.viewContext
|
lazy var managedObjectContext = coreDataStack.persistentContainer.viewContext
|
||||||
lazy var api: APIService = {
|
lazy var api: APIService = {
|
||||||
let backgroundManagedObjectContext = coreDataStack.newTaskContext()
|
let backgroundManagedObjectContext = coreDataStack.newTaskContext()
|
||||||
|
|
|
@ -20,7 +20,7 @@ public final class CoreDataStack {
|
||||||
self.storeDescriptions = storeDescriptions
|
self.storeDescriptions = storeDescriptions
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init(databaseName: String = "shared", isInMemory: Bool) {
|
public convenience init(databaseName: String = "shared", isInMemory: Bool = false) {
|
||||||
let storeURL = URL.storeURL(for: AppName.groupID, databaseName: databaseName)
|
let storeURL = URL.storeURL(for: AppName.groupID, databaseName: databaseName)
|
||||||
let storeDescription: NSPersistentStoreDescription
|
let storeDescription: NSPersistentStoreDescription
|
||||||
if isInMemory {
|
if isInMemory {
|
||||||
|
|
|
@ -48,21 +48,16 @@ public class AppContext: ObservableObject {
|
||||||
public init() {
|
public init() {
|
||||||
|
|
||||||
let authProvider = AuthenticationServiceProvider.shared
|
let authProvider = AuthenticationServiceProvider.shared
|
||||||
let _coreDataStack: CoreDataStack
|
let _coreDataStack = CoreDataStack()
|
||||||
if authProvider.authenticationMigrationRequired {
|
if authProvider.authenticationMigrationRequired {
|
||||||
_coreDataStack = CoreDataStack(isInMemory: false)
|
|
||||||
authProvider.migrateLegacyAuthentications(
|
authProvider.migrateLegacyAuthentications(
|
||||||
in: _coreDataStack.persistentContainer.viewContext
|
in: _coreDataStack.persistentContainer.viewContext
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
_coreDataStack = CoreDataStack(isInMemory: true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let _managedObjectContext = _coreDataStack.persistentContainer.viewContext
|
let _managedObjectContext = _coreDataStack.persistentContainer.viewContext
|
||||||
_coreDataStack.persistentContainer.persistentStoreDescriptions.forEach {
|
|
||||||
$0.url = URL(fileURLWithPath: "/dev/null")
|
|
||||||
}
|
|
||||||
let _backgroundManagedObjectContext = _coreDataStack.persistentContainer.newBackgroundContext()
|
let _backgroundManagedObjectContext = _coreDataStack.persistentContainer.newBackgroundContext()
|
||||||
|
|
||||||
coreDataStack = _coreDataStack
|
coreDataStack = _coreDataStack
|
||||||
managedObjectContext = _managedObjectContext
|
managedObjectContext = _managedObjectContext
|
||||||
backgroundManagedObjectContext = _backgroundManagedObjectContext
|
backgroundManagedObjectContext = _backgroundManagedObjectContext
|
||||||
|
|
|
@ -89,6 +89,8 @@ public extension AuthenticationServiceProvider {
|
||||||
|
|
||||||
if migratedAuthentications.count != legacyAuthentications.count {
|
if migratedAuthentications.count != legacyAuthentications.count {
|
||||||
logger.log(level: .default, "Not all account authentications could be migrated.")
|
logger.log(level: .default, "Not all account authentications could be migrated.")
|
||||||
|
} else {
|
||||||
|
logger.log(level: .default, "All account authentications were successful.")
|
||||||
}
|
}
|
||||||
|
|
||||||
self.authentications = migratedAuthentications
|
self.authentications = migratedAuthentications
|
||||||
|
|
Loading…
Reference in New Issue