Updates + migrates Core Data model to v2

This commit is contained in:
Riley Testut
2019-09-14 12:38:53 -07:00
parent ad69b9989c
commit 9f9710c31d
9 changed files with 658 additions and 51 deletions

View File

@@ -131,6 +131,20 @@ private extension DatabaseManager
context.performAndWait {
guard let localApp = ALTApplication(fileURL: Bundle.main.bundleURL) else { return }
let altStoreSource: Source
if let source = Source.first(satisfying: NSPredicate(format: "%K == %@", #keyPath(Source.identifier), Source.altStoreIdentifier), in: context)
{
altStoreSource = source
}
else
{
altStoreSource = Source.makeAltStoreSource(in: context)
}
// Make sure to always update source URL to be current.
altStoreSource.sourceURL = Source.altStoreSourceURL
let storeApp: StoreApp
if let app = StoreApp.first(satisfying: NSPredicate(format: "%K == %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID), in: context)
@@ -139,13 +153,11 @@ private extension DatabaseManager
}
else
{
let source = Source.makeAltStoreSource(in: context)
storeApp = StoreApp.makeAltStoreApp(in: context)
storeApp.version = localApp.version
storeApp.source = source
storeApp.source = altStoreSource
}
let installedApp: InstalledApp
if let app = storeApp.installedApp