Exporting: No need to check for duplicate names - we disallow it at creation time itself
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
@@ -68,19 +68,12 @@ class SettingsTableViewController: UITableViewController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var inputsToArchiver: [(fileName: String, contents: Data)] = []
|
var inputsToArchiver: [(fileName: String, contents: Data)] = []
|
||||||
var usedNames: Set<String> = []
|
|
||||||
for i in 0 ..< tunnelsManager.numberOfTunnels() {
|
for i in 0 ..< tunnelsManager.numberOfTunnels() {
|
||||||
guard let tunnelConfiguration = tunnelsManager.tunnel(at: i).tunnelConfiguration() else { continue }
|
guard let tunnelConfiguration = tunnelsManager.tunnel(at: i).tunnelConfiguration() else { continue }
|
||||||
if let contents = WgQuickConfigFileWriter.writeConfigFile(from: tunnelConfiguration) {
|
if let contents = WgQuickConfigFileWriter.writeConfigFile(from: tunnelConfiguration) {
|
||||||
let name = tunnelConfiguration.interface.name
|
let name = tunnelConfiguration.interface.name
|
||||||
var nameToCheck = name
|
assert(name != tunnelsManager.tunnel(at: i - 1).name)
|
||||||
var i = 0
|
inputsToArchiver.append((fileName: "\(name).conf", contents: contents))
|
||||||
while (usedNames.contains(nameToCheck)) {
|
|
||||||
i = i + 1
|
|
||||||
nameToCheck = "\(name)\(i)"
|
|
||||||
}
|
|
||||||
usedNames.insert(nameToCheck)
|
|
||||||
inputsToArchiver.append((fileName: "\(nameToCheck).conf", contents: contents))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user