Fix wrong spell in path.

This commit is contained in:
Charlie Qiu
2016-06-25 09:44:51 +08:00
parent fa6d9d64de
commit 2ef7adde6e
2 changed files with 24 additions and 7 deletions

View File

@ -9,9 +9,9 @@
import Foundation
let SS_LOCAL_VERSION = "2.4.6"
let APP_SUPPORT_DIR = "/Library/Application Support/ShadowsocksX-NE/"
let APP_SUPPORT_DIR = "/Library/Application Support/ShadowsocksX-NG/"
let LAUNCH_AGENT_DIR = "/Library/LaunchAgents/"
let LAUNCH_AGENT_CONF_NAME = "com.qiuyuzhou.shadowsocksX-NE.local.plist"
let LAUNCH_AGENT_CONF_NAME = "com.qiuyuzhou.shadowsocksX-NG.local.plist"
func getFileSHA1Sum(filepath: String) -> String {

View File

@ -9,7 +9,9 @@
import Foundation
import Alamofire
let PACRulesDirPath = NSHomeDirectory() + "/.ShadowsocksX-NE/"
let OldErrorPACRulesDirPath = NSHomeDirectory() + "/.ShadowsocksX-NE/"
let PACRulesDirPath = NSHomeDirectory() + "/.ShadowsocksX-NG/"
let PACUserRuleFilePath = PACRulesDirPath + "user-rule.txt"
let PACFilePath = PACRulesDirPath + "gfwlist.js"
let GFWListFilePath = PACRulesDirPath + "gfwlist.txt"
@ -17,12 +19,23 @@ let GFWListFilePath = PACRulesDirPath + "gfwlist.txt"
// Because of LocalSocks5.ListenPort may be changed
func SyncPac() {
var needGenerate = false
let nowSocks5Port = NSUserDefaults.standardUserDefaults().integerForKey("LocalSocks5.ListenPort")
let oldSocks5Port = NSUserDefaults.standardUserDefaults().integerForKey("LocalSocks5.ListenPort.Old")
if nowSocks5Port != oldSocks5Port {
GeneratePACFile()
needGenerate = true
NSUserDefaults.standardUserDefaults().setInteger(nowSocks5Port, forKey: "LocalSocks5.ListenPort.Old")
}
let fileMgr = NSFileManager.defaultManager()
if !fileMgr.fileExistsAtPath(PACRulesDirPath) {
needGenerate = true
}
if needGenerate {
GeneratePACFile()
}
}
@ -30,8 +43,12 @@ func GeneratePACFile() -> Bool {
let fileMgr = NSFileManager.defaultManager()
// Maker the dir if rulesDirPath is not exesited.
if !fileMgr.fileExistsAtPath(PACRulesDirPath) {
try! fileMgr.createDirectoryAtPath(PACRulesDirPath
, withIntermediateDirectories: true, attributes: nil)
if fileMgr.fileExistsAtPath(OldErrorPACRulesDirPath) {
try! fileMgr.moveItemAtPath(OldErrorPACRulesDirPath, toPath: PACRulesDirPath)
} else {
try! fileMgr.createDirectoryAtPath(PACRulesDirPath
, withIntermediateDirectories: true, attributes: nil)
}
}
// If gfwlist.txt is not exsited, copy from bundle
@ -40,7 +57,7 @@ func GeneratePACFile() -> Bool {
try! fileMgr.copyItemAtPath(src!, toPath: GFWListFilePath)
}
// If gfwlist.txt is not exsited, copy from bundle
// If user-rule.txt is not exsited, copy from bundle
if !fileMgr.fileExistsAtPath(PACUserRuleFilePath) {
let src = NSBundle.mainBundle().pathForResource("user-rule", ofType: "txt")
try! fileMgr.copyItemAtPath(src!, toPath: PACUserRuleFilePath)