mirror of
https://github.com/passepartoutvpn/wireguard-apple.git
synced 2025-02-22 15:52:05 +00:00
Settings: Export log: Perform file operations in a background thread
This commit is contained in:
parent
3af543a352
commit
aa915fc54c
@ -96,6 +96,8 @@ class SettingsTableViewController: UITableViewController {
|
|||||||
let timeStampString = dateFormatter.string(from: Date())
|
let timeStampString = dateFormatter.string(from: Date())
|
||||||
let destinationURL = destinationDir.appendingPathComponent("wireguard-log-\(timeStampString).txt")
|
let destinationURL = destinationDir.appendingPathComponent("wireguard-log-\(timeStampString).txt")
|
||||||
|
|
||||||
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
|
|
||||||
if (FileManager.default.fileExists(atPath: destinationURL.path)) {
|
if (FileManager.default.fileExists(atPath: destinationURL.path)) {
|
||||||
let isDeleted = FileManager.deleteFile(at: destinationURL)
|
let isDeleted = FileManager.deleteFile(at: destinationURL)
|
||||||
if (!isDeleted) {
|
if (!isDeleted) {
|
||||||
@ -118,6 +120,7 @@ class SettingsTableViewController: UITableViewController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
let activityVC = UIActivityViewController(activityItems: [destinationURL], applicationActivities: nil)
|
let activityVC = UIActivityViewController(activityItems: [destinationURL], applicationActivities: nil)
|
||||||
// popoverPresentationController shall be non-nil on the iPad
|
// popoverPresentationController shall be non-nil on the iPad
|
||||||
activityVC.popoverPresentationController?.sourceView = sourceView
|
activityVC.popoverPresentationController?.sourceView = sourceView
|
||||||
@ -128,6 +131,8 @@ class SettingsTableViewController: UITableViewController {
|
|||||||
}
|
}
|
||||||
self.present(activityVC, animated: true)
|
self.present(activityVC, animated: true)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: UITableViewDataSource
|
// MARK: UITableViewDataSource
|
||||||
|
Loading…
Reference in New Issue
Block a user