aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-10-29 02:03:30 +0530
committerRoopesh Chander <roop@roopc.net>2018-10-29 02:03:39 +0530
commitb5ef62ddee91e33bde5edf31fcd1104b891a0f43 (patch)
treeae8f08e72bed00682da45710bbdf751ee5f76d79
parentImport config: Directly add config, don't open up the editor (diff)
downloadwireguard-apple-b5ef62ddee91e33bde5edf31fcd1104b891a0f43.tar.xz
wireguard-apple-b5ef62ddee91e33bde5edf31fcd1104b891a0f43.zip
Import: Show errors when importing fails
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift8
1 files changed, 8 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift
index ee5e3ac..22ef487 100644
--- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift
@@ -149,6 +149,8 @@ extension TunnelsListTableViewController: UIDocumentPickerDelegate {
print("Error adding configuration: \(tunnelConfiguration.interface.name)")
}
}
+ } else {
+ showErrorAlert(title: "Could not import", message: "The config file contained errors")
}
} else if (url.pathExtension == "zip") {
var unarchivedFiles: [(fileName: String, contents: Data)] = []
@@ -161,6 +163,7 @@ extension TunnelsListTableViewController: UIDocumentPickerDelegate {
} catch (let error) {
print("Error opening zip archive: \(error)")
}
+ var numberOfConfigFilesWithErrors = 0
for unarchivedFile in unarchivedFiles {
if let fileBaseName = URL(string: unarchivedFile.fileName)?.deletingPathExtension().lastPathComponent,
let fileContents = String(data: unarchivedFile.contents, encoding: .utf8),
@@ -170,8 +173,13 @@ extension TunnelsListTableViewController: UIDocumentPickerDelegate {
print("Error adding configuration: \(tunnelConfiguration.interface.name)")
}
}
+ } else {
+ numberOfConfigFilesWithErrors = numberOfConfigFilesWithErrors + 1
}
}
+ if (numberOfConfigFilesWithErrors > 0) {
+ showErrorAlert(title: "Could not import \(numberOfConfigFilesWithErrors) files", message: "\(numberOfConfigFilesWithErrors) of \(unarchivedFiles.count) files contained errors and were not imported")
+ }
}
}
}