From d55672970581ed435dda91f8273b1761ab3d8777 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Wed, 14 Nov 2018 19:17:18 +0530 Subject: [PATCH] Exporting: No need to check for duplicate names - we disallow it at creation time itself Signed-off-by: Roopesh Chander --- .../UI/iOS/SettingsTableViewController.swift | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift index fac2005..4024213 100644 --- a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift @@ -68,19 +68,12 @@ class SettingsTableViewController: UITableViewController { return } var inputsToArchiver: [(fileName: String, contents: Data)] = [] - var usedNames: Set = [] for i in 0 ..< tunnelsManager.numberOfTunnels() { guard let tunnelConfiguration = tunnelsManager.tunnel(at: i).tunnelConfiguration() else { continue } if let contents = WgQuickConfigFileWriter.writeConfigFile(from: tunnelConfiguration) { let name = tunnelConfiguration.interface.name - var nameToCheck = name - var i = 0 - while (usedNames.contains(nameToCheck)) { - i = i + 1 - nameToCheck = "\(name)\(i)" - } - usedNames.insert(nameToCheck) - inputsToArchiver.append((fileName: "\(nameToCheck).conf", contents: contents)) + assert(name != tunnelsManager.tunnel(at: i - 1).name) + inputsToArchiver.append((fileName: "\(name).conf", contents: contents)) } }