Fix a bug when importing SSH Key from URL

This commit is contained in:
Mingshen Sun 2019-07-17 23:43:28 -07:00
parent 7cf9311f95
commit 90bc399c9f
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 8 additions and 8 deletions

View file

@ -17,20 +17,20 @@ class SSHKeySettingTableViewController: AutoCellHeightUITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
privateKeyURLTextField.text = SharedDefaults[.gitSSHPrivateKeyURL]?.absoluteString
}
@IBAction func doneButtonTapped(_ sender: UIButton) {
guard let privateKeyURL = URL(string: privateKeyURLTextField.text!.trimmed) else {
Utils.alert(title: "CannotSave".localize(), message: "SetPrivateKeyUrl.".localize(), controller: self, completion: nil)
return
}
SharedDefaults[.gitSSHPrivateKeyURL] = privateKeyURL
do {
try Data(contentsOf: privateKeyURL).write(to: URL(fileURLWithPath: Globals.gitSSHPrivateKeyPath), options: .atomic)
try Data(contentsOf: privateKeyURL).write(to: URL(fileURLWithPath: SshKey.PRIVATE.getFileSharingPath()), options: .atomic)
try self.passwordStore.gitSSHKeyImportFromFileSharing()
SharedDefaults[.gitSSHKeySource] = "file"
SVProgressHUD.showSuccess(withStatus: "Imported".localize())
SVProgressHUD.dismiss(withDelay: 1)
} catch {
Utils.alert(title: "Error".localize(), message: error.localizedDescription, controller: self, completion: nil)
}