From dc718a583b6fd1ac01d3ef61047b06987ec89313 Mon Sep 17 00:00:00 2001 From: Liming Jin Date: Sun, 10 Dec 2017 17:20:22 +0800 Subject: [PATCH] Put user rules at the begin of the PAC file. Fix: #1468 Enhance: 46d40fec678c7ab3c1cd6743e675aa13b6d6af77 --- .../Controller/Service/GfwListUpdater.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs b/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs index 30cd7d34..d59fcec3 100644 --- a/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs +++ b/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs @@ -36,7 +36,7 @@ namespace Shadowsocks.Controller try { File.WriteAllText(Utils.GetTempPath("gfwlist.txt"), e.Result, Encoding.UTF8); - List lines = ParseResult(e.Result); + List lines = new List(); if (File.Exists(PACServer.USER_RULE_FILE)) { string local = FileManager.NonExclusiveReadAllText(PACServer.USER_RULE_FILE, Encoding.UTF8); @@ -50,6 +50,7 @@ namespace Shadowsocks.Controller } } } + lines.AddRange(ParseResult(e.Result)); string abpContent; if (File.Exists(PACServer.USER_ABP_FILE)) { @@ -70,17 +71,11 @@ namespace Shadowsocks.Controller } } File.WriteAllText(PACServer.PAC_FILE, abpContent, Encoding.UTF8); - if (UpdateCompleted != null) - { - UpdateCompleted(this, new ResultEventArgs(true)); - } + UpdateCompleted?.Invoke(this, new ResultEventArgs(true)); } catch (Exception ex) { - if (Error != null) - { - Error(this, new ErrorEventArgs(ex)); - } + Error?.Invoke(this, new ErrorEventArgs(ex)); } }