From 3fd8ba864ae73bcfc2440299b90b0b89d9ab89b6 Mon Sep 17 00:00:00 2001 From: Qiu Yuzhou Date: Mon, 11 Nov 2019 10:26:41 +0800 Subject: [PATCH] Fixes #1185. Make sure the folder `~/.ShadowsocksX-NG` exists. --- ShadowsocksX-NG/LaunchAgentUtils.swift | 10 +++++++++- ShadowsocksX-NG/PACUtils.swift | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ShadowsocksX-NG/LaunchAgentUtils.swift b/ShadowsocksX-NG/LaunchAgentUtils.swift index e6b37c0..d1feafc 100644 --- a/ShadowsocksX-NG/LaunchAgentUtils.swift +++ b/ShadowsocksX-NG/LaunchAgentUtils.swift @@ -335,7 +335,15 @@ func InstallPrivoxy() { } } - let userConfigPath = homeDir + USER_CONFIG_DIR + "user-privoxy.config" + let userConfigDir = homeDir + USER_CONFIG_DIR + // Make dir: '~/.ShadowsocksX-NG' + if !fileMgr.fileExists(atPath: userConfigDir) { + try! fileMgr.createDirectory(atPath: userConfigDir + , withIntermediateDirectories: true, attributes: nil) + } + + // Install empty `user-privoxy.config` file. + let userConfigPath = userConfigDir + "user-privoxy.config" if !fileMgr.fileExists(atPath: userConfigPath) { let srcPath = Bundle.main.path(forResource: "user-privoxy", ofType: "config")! try! fileMgr.copyItem(atPath: srcPath, toPath: userConfigPath) diff --git a/ShadowsocksX-NG/PACUtils.swift b/ShadowsocksX-NG/PACUtils.swift index 6977895..08e5fa1 100644 --- a/ShadowsocksX-NG/PACUtils.swift +++ b/ShadowsocksX-NG/PACUtils.swift @@ -36,7 +36,7 @@ func SyncPac() { } let fileMgr = FileManager.default - if !fileMgr.fileExists(atPath: PACRulesDirPath) { + if !fileMgr.fileExists(atPath: PACFilePath) { needGenerate = true }