Improve: loop check helper status at startup

This commit is contained in:
yicheng 2019-11-22 23:06:20 +08:00
parent f3ff0afec5
commit 4a9822b3a7
1 changed files with 9 additions and 9 deletions

View File

@ -45,14 +45,14 @@ class SystemProxyManager: NSObject {
func checkInstall() {
Logger.log("checkInstall", level: .debug)
let installed = helperStatus()
if installed { return }
Logger.log("need to install helper", level: .debug)
if Thread.isMainThread {
notifyInstall()
} else {
DispatchQueue.main.async {
self.notifyInstall()
while !helperStatus() {
Logger.log("need to install helper", level: .debug)
if Thread.isMainThread {
notifyInstall()
} else {
DispatchQueue.main.async {
self.notifyInstall()
}
}
}
}
@ -223,7 +223,7 @@ class SystemProxyManager: NSObject {
return false
}
let helperFileExists = FileManager.default.fileExists(atPath: "/Library/PrivilegedHelperTools/com.west2online.ClashX.ProxyConfigHelper")
let timeout: TimeInterval = helperFileExists ? 8 : 2
let timeout: TimeInterval = helperFileExists ? 15 : 2
var installed = false
let time = Date()
let semaphore = DispatchSemaphore(value: 0)