From e83cef1c8cf421283268da8ed4cba40b1cad1adf Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 18 Apr 2024 11:45:32 -0400 Subject: [PATCH] Fix overzealously attempting to migrate local data to cloud store Fix error when actually migrating due to not opening the store with NSPersistentHistoryTrackingKey set to true. --- Tusker/CoreData/MastodonCachePersistentStore.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tusker/CoreData/MastodonCachePersistentStore.swift b/Tusker/CoreData/MastodonCachePersistentStore.swift index 7062d762..837f0834 100644 --- a/Tusker/CoreData/MastodonCachePersistentStore.swift +++ b/Tusker/CoreData/MastodonCachePersistentStore.swift @@ -124,12 +124,13 @@ class MastodonCachePersistentStore: NSPersistentCloudKitContainer { // migrate saved data from local store to cloud store // this can be removed pre-app store release - var defaultPath = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first! - defaultPath.appendPathComponent("\(accountInfo!.persistenceKey)_cache.sqlite", isDirectory: false) - if FileManager.default.fileExists(atPath: defaultPath.path) { + if !FileManager.default.fileExists(atPath: cloudStoreLocation.path) { group.enter() + var defaultPath = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first! + defaultPath.appendPathComponent("\(accountInfo!.persistenceKey)_cache.sqlite", isDirectory: false) let defaultDesc = NSPersistentStoreDescription(url: defaultPath) defaultDesc.configuration = "Default" + defaultDesc.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) let defaultPSC = NSPersistentContainer(name: "\(accountInfo!.persistenceKey)_cache", managedObjectModel: MastodonCachePersistentStore.managedObjectModel) defaultPSC.persistentStoreDescriptions = [defaultDesc] defaultPSC.loadPersistentStores { _, error in