Skip to content

Commit

Permalink
Fix crash due to db operation on different thread (#138)
Browse files Browse the repository at this point in the history
* Fix issue where field name is used for fetching property type instead of property name, resulting in crash when field name is "FieldName" and property name is "fieldname", since it wont get the property type as data

* add in perform and wait since its a db operation, else it can cause a crash
  • Loading branch information
SajuThomasPattarmatam authored Jun 28, 2022
1 parent d03147d commit e30c007
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/ContentfulPersistence/SynchronizationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ public class SynchronizationManager: PersistenceIntegration {
- parameter limit: Number of elements per page. See documentation for details.
*/
public func sync(limit: Int? = nil, dbVersion: Int = DBVersions.default.rawValue, then completion: @escaping ResultsHandler<SyncSpace>) {
// If the migration is required - it will be performed before any new changed takes affect
migrateDbIfNeeded(dbVersion: dbVersion)
persistentStore.performAndWait { [weak self] in
// If the migration is required - it will be performed before any new changed takes affect
self?.migrateDbIfNeeded(dbVersion: dbVersion)
}

resolveCachedRelationships { [weak self] in
self?.syncSafely(limit: limit, then: completion)
Expand Down

0 comments on commit e30c007

Please sign in to comment.