Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
fix issue #62
Browse files Browse the repository at this point in the history
  • Loading branch information
ParadiseDuo authored and ParadiseDuo committed Aug 28, 2020
1 parent 454ea2e commit eaf251b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions ShadowsocksX-NG/Configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ static NSString * const USERDEFAULTS_FIXED_NETWORK_SPEED_VIEW_WIDTH = @"FIXED_NE
static NSString * const USERDEFAULTS_REMOVE_NODE_AFTER_DELETE_SUBSCRIPTION = @"REMOVE_NODE_AFTER_DELETE_SUBSCRIPTION";
static NSString * const USERDEFAULTS_PROXY_EXCEPTIONS = @"ProxyExceptions";
static NSString * const USERDEFAULTS_SERVERS_LIST_SHOW_SERVER_AND_PORT = @"SERVERS_LIST_SHOW_SERVER_AND_PORT";
static NSString * const USERDEFAULTS_SERVERS_USER_RULE_FILE_SHA1 = @"USERDEFAULTS_SERVERS_USER_RULE_FILE_SHA1";

#endif /* Configure_h */
14 changes: 14 additions & 0 deletions ShadowsocksX-NG/PACUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ func SyncPac() {
let fileMgr = FileManager.default
if !fileMgr.fileExists(atPath: PACRulesDirPath) {
needGenerate = true
} else {
if let oldSha1Sum = UserDefaults.standard.object(forKey: USERDEFAULTS_SERVERS_USER_RULE_FILE_SHA1) as? String {
let newSha1 = getFileSHA1Sum(PACUserRuleFilePath)
if newSha1 != oldSha1Sum {
needGenerate = true
UserDefaults.standard.set(newSha1, forKey: USERDEFAULTS_SERVERS_USER_RULE_FILE_SHA1)
UserDefaults.standard.synchronize()
}
} else {
UserDefaults.standard.set(getFileSHA1Sum(PACUserRuleFilePath), forKey: USERDEFAULTS_SERVERS_USER_RULE_FILE_SHA1)
UserDefaults.standard.synchronize()
}
}

if !fileMgr.fileExists(atPath: ACLWhiteListFilePath) && !fileMgr.fileExists(atPath: ACLBackCHNFilePath) {
Expand Down Expand Up @@ -101,6 +113,8 @@ func GeneratePACFile() -> Bool {
var lines = str!.components(separatedBy: CharacterSet.newlines)

do {
UserDefaults.standard.set(getFileSHA1Sum(PACUserRuleFilePath), forKey: USERDEFAULTS_SERVERS_USER_RULE_FILE_SHA1)
UserDefaults.standard.synchronize()
let userRuleStr = try String(contentsOfFile: PACUserRuleFilePath, encoding: String.Encoding.utf8)
let userRuleLines = userRuleStr.components(separatedBy: CharacterSet.newlines)

Expand Down

0 comments on commit eaf251b

Please sign in to comment.