Fix the logic of git clone

- erase git password and ssh passphrase before cloning
- erase core data after a failed cloning
This commit is contained in:
Yishi Lin 2017-08-12 21:41:34 +08:00
parent aa4ff7ce47
commit 6d118eab7e
3 changed files with 15 additions and 7 deletions

View file

@ -291,6 +291,8 @@ public class PasswordStore {
checkoutProgressBlock: @escaping (String?, UInt, UInt) -> Void) throws {
Utils.removeFileIfExists(at: storeURL)
Utils.removeFileIfExists(at: tempStoreURL)
self.gitPassword = nil
self.gitSSHPrivateKeyPassphrase = nil
do {
let credentialProvider = try credential.credentialProvider(requestGitPassword: requestGitPassword)
let options = [GTRepositoryCloneOptionsCredentialProvider: credentialProvider]
@ -302,6 +304,11 @@ public class PasswordStore {
storeRepository = try GTRepository(url: storeURL)
} catch {
credential.delete()
DispatchQueue.main.async {
SharedDefaults[.lastSyncedTime] = nil
self.deleteCoreData(entityName: "PasswordEntity")
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
}
throw(error)
}
DispatchQueue.main.async {