mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-18 11:13:28 +01:00
Resolves AppVersion context-level conflict after migrating from Core Data model v10
This commit is contained in:
@@ -39,6 +39,18 @@ open class MergePolicy: RSTRelationshipPreservingMergePolicy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case is AppVersion where conflict.conflictingObjects.count == 2:
|
||||||
|
// Occurs first time fetching sources after migrating from pre-AppVersion database model.
|
||||||
|
let conflictingAppVersions = conflict.conflictingObjects.lazy.compactMap { $0 as? AppVersion }
|
||||||
|
|
||||||
|
// Primary AppVersion == AppVersion whose latestVersionApp.latestVersion points back to itself.
|
||||||
|
if let primaryAppVersion = conflictingAppVersions.first(where: { $0.latestVersionApp?.latestVersion == $0 }),
|
||||||
|
let secondaryAppVersion = conflictingAppVersions.first(where: { $0 != primaryAppVersion })
|
||||||
|
{
|
||||||
|
secondaryAppVersion.managedObjectContext?.delete(secondaryAppVersion)
|
||||||
|
print("[ALTLog] Resolving AppVersion context-level conflict. Most likely due to migrating from pre-AppVersion model version.", primaryAppVersion)
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Unknown context-level conflict.
|
// Unknown context-level conflict.
|
||||||
assertionFailure("MergePolicy is only intended to work with database-level conflicts.")
|
assertionFailure("MergePolicy is only intended to work with database-level conflicts.")
|
||||||
|
|||||||
Reference in New Issue
Block a user