Forward input passphrase to parser

This commit is contained in:
Davide De Rosa 2019-03-25 19:15:48 +01:00
parent dc81356b31
commit 8f0e28e315
3 changed files with 4 additions and 4 deletions

View File

@ -101,7 +101,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
let passphraseBlock = { (passphrase) in
_ = self.tryParseURL(url, passphrase: passphrase, target: target)
}
guard let parsingResult = ConfigurationParser.ParsingResult.from(url, withErrorAlertIn: target, passphraseBlock: passphraseBlock) else {
guard let parsingResult = ConfigurationParser.ParsingResult.from(url, withErrorAlertIn: target, passphrase: passphrase, passphraseBlock: passphraseBlock) else {
return true
}
if let warning = parsingResult.warning {

View File

@ -32,13 +32,13 @@ import Passepartout_Core
private let log = SwiftyBeaver.self
extension ConfigurationParser.ParsingResult {
static func from(_ url: URL, withErrorAlertIn viewController: UIViewController, passphraseBlock: @escaping (String) -> Void) -> ConfigurationParser.ParsingResult? {
static func from(_ url: URL, withErrorAlertIn viewController: UIViewController, passphrase: String?, passphraseBlock: @escaping (String) -> Void) -> ConfigurationParser.ParsingResult? {
let result: ConfigurationParser.ParsingResult
let fm = FileManager.default
log.debug("Parsing configuration URL: \(url)")
do {
result = try ConfigurationParser.parsed(fromURL: url)
result = try ConfigurationParser.parsed(fromURL: url, passphrase: passphrase)
} catch let e as ConfigurationParser.ParsingError {
switch e {
case .encryptionPassphrase, .unableToDecrypt(_):

View File

@ -88,7 +88,7 @@ class ImportedHostsViewController: UITableViewController {
}
self.perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier, sender: cell)
}
guard let parsingResult = ConfigurationParser.ParsingResult.from(url, withErrorAlertIn: self, passphraseBlock: passphraseBlock) else {
guard let parsingResult = ConfigurationParser.ParsingResult.from(url, withErrorAlertIn: self, passphrase: passphrase, passphraseBlock: passphraseBlock) else {
deselectSelectedRow()
return false
}