No need to import SSH public key

This commit is contained in:
Yishi Lin 2017-06-07 01:06:53 +08:00
parent 7bfc3cc7d4
commit a31f5b797d
8 changed files with 38 additions and 122 deletions

View file

@ -13,31 +13,23 @@ import SVProgressHUD
class SSHKeySettingTableViewController: UITableViewController {
@IBOutlet weak var privateKeyURLTextField: UITextField!
@IBOutlet weak var publicKeyURLTextField: UITextField!
let passwordStore = PasswordStore.shared
override func viewDidLoad() {
super.viewDidLoad()
privateKeyURLTextField.text = Defaults[.gitSSHPrivateKeyURL]?.absoluteString
publicKeyURLTextField.text = Defaults[.gitSSHPublicKeyURL]?.absoluteString
}
@IBAction func doneButtonTapped(_ sender: UIButton) {
guard let publicKeyURL = URL(string: publicKeyURLTextField.text!) else {
Utils.alert(title: "Cannot Save", message: "Please set Public Key URL first.", controller: self, completion: nil)
return
}
guard let privateKeyURL = URL(string: privateKeyURLTextField.text!) else {
Utils.alert(title: "Cannot Save", message: "Please set Private Key URL first.", controller: self, completion: nil)
return
}
Defaults[.gitSSHPublicKeyURL] = publicKeyURL
Defaults[.gitSSHPrivateKeyURL] = privateKeyURL
do {
try Data(contentsOf: publicKeyURL).write(to: URL(fileURLWithPath: Globals.gitSSHPublicKeyPath), options: .atomic)
try Data(contentsOf: privateKeyURL).write(to: URL(fileURLWithPath: Globals.gitSSHPrivateKeyPath), options: .atomic)
} catch {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)