From f89952dd180790a26b955abe370ae13f703c6580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Wed, 16 Jun 2021 14:33:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=88=96=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.Scanner/GithubContextCollection.cs | 12 ++++++++++-- FastGithub.Scanner/GithubScanService.cs | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/FastGithub.Scanner/GithubContextCollection.cs b/FastGithub.Scanner/GithubContextCollection.cs index 5c01444..3abf00d 100644 --- a/FastGithub.Scanner/GithubContextCollection.cs +++ b/FastGithub.Scanner/GithubContextCollection.cs @@ -10,11 +10,19 @@ namespace FastGithub.Scanner private readonly HashSet contextHashSet = new(); private readonly Dictionary domainAdressCache = new(); - public bool Add(GithubContext context) + public void AddOrUpdate(GithubContext context) { lock (this.syncRoot) { - return this.contextHashSet.Add(context); + if (this.contextHashSet.TryGetValue(context, out var value)) + { + value.Elapsed = context.Elapsed; + value.Available = context.Available; + } + else + { + this.contextHashSet.Add(context); + } } } diff --git a/FastGithub.Scanner/GithubScanService.cs b/FastGithub.Scanner/GithubScanService.cs index a1d3d7d..480b573 100644 --- a/FastGithub.Scanner/GithubScanService.cs +++ b/FastGithub.Scanner/GithubScanService.cs @@ -62,7 +62,7 @@ namespace FastGithub.Scanner await this.fullScanDelegate(context); if (context.Available == true) { - this.results.Add(context); + this.results.AddOrUpdate(context); } } }