diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index 00e5665..a56fca0 100755 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -116,7 +116,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele _ = notifyCenter.rx.notification(NOTIFY_CONF_CHANGED) .subscribe(onNext: { noti in - SyncSSLocal() self.applyConfig() self.updateCopyHttpProxyExportMenu() }) diff --git a/ShadowsocksX-NG/LaunchAgentUtils.swift b/ShadowsocksX-NG/LaunchAgentUtils.swift index 04124aa..00051e6 100644 --- a/ShadowsocksX-NG/LaunchAgentUtils.swift +++ b/ShadowsocksX-NG/LaunchAgentUtils.swift @@ -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.") diff --git a/ShadowsocksX-NG/ServerProfileManager.swift b/ShadowsocksX-NG/ServerProfileManager.swift index e06ea00..8eb733c 100644 --- a/ShadowsocksX-NG/ServerProfileManager.swift +++ b/ShadowsocksX-NG/ServerProfileManager.swift @@ -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? {