Delete openURL .ovpn on Cancel

This commit is contained in:
Davide De Rosa 2018-10-27 13:20:23 +02:00
parent 0d23187eef
commit 42c94c3a14
2 changed files with 7 additions and 0 deletions

View File

@ -99,6 +99,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
// already presented: update parsed configuration
if let nav = root.presentedViewController as? UINavigationController, let wizard = nav.topViewController as? WizardHostViewController {
wizard.parsedFile = parsedFile
wizard.removesConfigurationOnCancel = true
return true
}
@ -108,6 +109,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
fatalError("Expected WizardHostViewController from storyboard")
}
wizard.parsedFile = parsedFile
wizard.removesConfigurationOnCancel = true
// best effort to delegate to main vc
let split = root as? UISplitViewController

View File

@ -42,6 +42,8 @@ class WizardHostViewController: UITableViewController, TableModelHost, Wizard {
}
}
var removesConfigurationOnCancel = false
private var createdProfile: HostConnectionProfile?
weak var delegate: WizardDelegate?
@ -148,6 +150,9 @@ class WizardHostViewController: UITableViewController, TableModelHost, Wizard {
}
@IBAction private func close() {
if removesConfigurationOnCancel, let url = parsedFile?.url {
try? FileManager.default.removeItem(at: url)
}
dismiss(animated: true, completion: nil)
}
}