Set PGP key source once for all key importers
This commit is contained in:
parent
e0c9ceb4fd
commit
43bba1fb50
4 changed files with 2 additions and 9 deletions
|
|
@ -148,8 +148,6 @@ extension PGPKeyArmorSettingTableViewController: PGPKeyImporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func importKeys() throws {
|
func importKeys() throws {
|
||||||
Defaults.pgpKeySource = Self.keySource
|
|
||||||
|
|
||||||
try KeyFileManager.PublicPgp.importKey(from: armorPublicKeyTextView.text ?? "")
|
try KeyFileManager.PublicPgp.importKey(from: armorPublicKeyTextView.text ?? "")
|
||||||
try KeyFileManager.PrivatePgp.importKey(from: armorPrivateKeyTextView.text ?? "")
|
try KeyFileManager.PrivatePgp.importKey(from: armorPrivateKeyTextView.text ?? "")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,6 @@ extension PGPKeyFileSettingTableViewController: PGPKeyImporter {
|
||||||
guard let publicKey = publicKey, let privateKey = privateKey else {
|
guard let publicKey = publicKey, let privateKey = privateKey else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Defaults.pgpKeySource = Self.keySource
|
|
||||||
|
|
||||||
try KeyFileManager.PublicPgp.importKey(from: publicKey)
|
try KeyFileManager.PublicPgp.importKey(from: publicKey)
|
||||||
try KeyFileManager.PrivatePgp.importKey(from: privateKey)
|
try KeyFileManager.PrivatePgp.importKey(from: privateKey)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,8 @@ extension PGPKeyUrlTableViewController: PGPKeyImporter {
|
||||||
return validate(pgpKeyUrl: pgpPublicKeyURLTextField.text)
|
return validate(pgpKeyUrl: pgpPublicKeyURLTextField.text)
|
||||||
&& validate(pgpKeyUrl: pgpPrivateKeyURLTextField.text)
|
&& validate(pgpKeyUrl: pgpPrivateKeyURLTextField.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func importKeys() throws {
|
|
||||||
Defaults.pgpKeySource = Self.keySource
|
|
||||||
|
|
||||||
|
func importKeys() throws {
|
||||||
Defaults.pgpPrivateKeyURL = URL(string: pgpPrivateKeyURLTextField.text!.trimmed)
|
Defaults.pgpPrivateKeyURL = URL(string: pgpPrivateKeyURLTextField.text!.trimmed)
|
||||||
Defaults.pgpPublicKeyURL = URL(string: pgpPublicKeyURLTextField.text!.trimmed)
|
Defaults.pgpPublicKeyURL = URL(string: pgpPublicKeyURLTextField.text!.trimmed)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
|
||||||
SVProgressHUD.setDefaultStyle(.light)
|
SVProgressHUD.setDefaultStyle(.light)
|
||||||
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())
|
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())
|
||||||
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
||||||
|
Defaults.pgpKeySource = type(of: keyImporter).keySource
|
||||||
do {
|
do {
|
||||||
try keyImporter.importKeys()
|
try keyImporter.importKeys()
|
||||||
try PGPAgent.shared.initKeys()
|
try PGPAgent.shared.initKeys()
|
||||||
|
|
@ -253,8 +254,6 @@ extension SettingsTableViewController: PGPKeyImporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func importKeys() throws {
|
func importKeys() throws {
|
||||||
Defaults.pgpKeySource = Self.keySource
|
|
||||||
|
|
||||||
try KeyFileManager.PublicPgp.importKeyFromFileSharing()
|
try KeyFileManager.PublicPgp.importKeyFromFileSharing()
|
||||||
try KeyFileManager.PrivatePgp.importKeyFromFileSharing()
|
try KeyFileManager.PrivatePgp.importKeyFromFileSharing()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue