Fixes bug.

ss-local has not been restarted after modified the current profile.
This commit is contained in:
Qiu Yuzhou
2018-02-06 16:38:54 +08:00
parent 97df9880ef
commit 85f868153a
3 changed files with 5 additions and 10 deletions

View File

@ -116,7 +116,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
_ = notifyCenter.rx.notification(NOTIFY_CONF_CHANGED)
.subscribe(onNext: { noti in
SyncSSLocal()
self.applyConfig()
self.updateCopyHttpProxyExportMenu()
})

View File

@ -70,8 +70,10 @@ func generateSSLocalLauchAgentPlist() -> Bool {
dict.write(toFile: plistFilepath, atomically: true)
let Sha1Sum = getFileSHA1Sum(plistFilepath)
if oldSha1Sum != Sha1Sum {
NSLog("generateSSLocalLauchAgentPlist - File has been changed.")
return true
} else {
NSLog("generateSSLocalLauchAgentPlist - File has not been changed.")
return false
}
}
@ -125,12 +127,14 @@ func writeSSLocalConfFile(_ conf:[String:AnyObject]) -> Bool {
let oldSum = getFileSHA1Sum(filepath)
try data.write(to: URL(fileURLWithPath: filepath), options: .atomic)
let newSum = getFileSHA1Sum(filepath)
let newSum = data.sha1()
if oldSum == newSum {
NSLog("writeSSLocalConfFile - File has not been changed.")
return false
}
NSLog("writeSSLocalConfFile - File has been changed.")
return true
} catch {
NSLog("Write ss-local file failed.")

View File

@ -48,14 +48,6 @@ class ServerProfileManager: NSObject {
if getActiveProfile() == nil {
activeProfileId = nil
}
if activeProfileId != nil {
defaults.set(activeProfileId, forKey: "ActiveServerProfileId")
_ = writeSSLocalConfFile((getActiveProfile()?.toJsonConfig())!)
} else {
defaults.removeObject(forKey: "ActiveServerProfileId")
removeSSLocalConfFile()
}
}
func getActiveProfile() -> ServerProfile? {