Fix pull to sync bug caused by manipulating core date in background thread

This commit is contained in:
Bob Sun 2017-03-29 22:59:30 -07:00
parent ba20d084e4
commit b85358a0b8
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -302,10 +302,11 @@ class PasswordStore {
}
storeRepository = try GTRepository(url: storeURL)
gitCredential = credential
self.updatePasswordEntityCoreData()
Defaults[.lastSyncedTime] = Date()
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
DispatchQueue.main.async {
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
self.updatePasswordEntityCoreData()
}
}
func pullRepository(transferProgressBlock: @escaping (UnsafePointer<git_transfer_progress>, UnsafeMutablePointer<ObjCBool>) -> Void) throws {
@ -318,11 +319,12 @@ class PasswordStore {
]
let remote = try GTRemote(name: "origin", in: storeRepository!)
try storeRepository?.pull((storeRepository?.currentBranch())!, from: remote, withOptions: options, progress: transferProgressBlock)
self.setAllSynced()
self.updatePasswordEntityCoreData()
Defaults[.lastSyncedTime] = Date()
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
DispatchQueue.main.async {
self.setAllSynced()
self.updatePasswordEntityCoreData()
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
}
}
private func updatePasswordEntityCoreData() {