Skip to content

Commit

Permalink
remove same nodes when update subscribes
Browse files Browse the repository at this point in the history
  • Loading branch information
AkaneAkaza committed Nov 23, 2017
1 parent 568e972 commit 278ccdb
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions shadowsocks-csharp/View/MenuViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e)
// import all, find difference
{
Dictionary<string, Server> old_servers = new Dictionary<string, Server>();
Dictionary<string, Server> old_insert_servers = new Dictionary<string, Server>();
if (!String.IsNullOrEmpty(lastGroup))
{
for (int i = config.configs.Count - 1; i >= 0; --i)
Expand All @@ -467,15 +468,30 @@ void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e)
{
Server server = new Server(url, curGroup);
bool match = false;
foreach (KeyValuePair<string, Server> pair in old_servers)
if (!match)
{
foreach (KeyValuePair<string, Server> pair in old_insert_servers)
{
if (server.isMatchServer(pair.Value))
{
match = true;
break;
}
}
}
old_insert_servers[server.id] = server;
if (!match)
{
if (server.isMatchServer(pair.Value))
foreach (KeyValuePair<string, Server> pair in old_servers)
{
match = true;
old_servers.Remove(pair.Key);
pair.Value.CopyServerInfo(server);
++count;
break;
if (server.isMatchServer(pair.Value))
{
match = true;
old_servers.Remove(pair.Key);
pair.Value.CopyServerInfo(server);
++count;
break;
}
}
}
if (!match)
Expand Down

0 comments on commit 278ccdb

Please sign in to comment.