-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(checker): 优化链接有效性检查中的 URL 检查部分 #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
GitHub Action Run 18054481111 Crash Report.
翻译: |
fix: 在复用调试结果时直接返回 true
依据实际结果,这个优化似乎对 默认 失败等级的运行时间没有明显优化,但对 详细 失败等级的运行时间有明显优化。 |
除了重复检查,超时也是影响检查时间的一大因素。但我们似乎只能通过忽略来处理这些超时的 URL。 |
我可能会考虑延迟这个 PR 的合并,因为这个优化尚不能证明稳定,且详细模式很少用到。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里有一些建议。
另外,在处理错误结果时都是
errorMessage = $"";
checkedUrls.TryAdd(url, errorMessage);
WriteErrorMessage(errorMessage, filePath);
的格式,也许我们可以建一个方法来统一这些?
|
||
Console.WriteLine("[INFO] 正在查找 URL..."); | ||
|
||
// 先收集所有 URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
由于现在没有去重,这里的收集也许可以简化?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我不知道该怎么简化。
errorMessage = $"\n[Debug] 访问 <ManifestFilePath> 中的 {url} 时发生错误: {e.Message} (资源暂时不可用)"; | ||
checkedUrls.TryAdd(url, errorMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个结果似乎也不应存储?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我不确定发布者多久能修复这个错误。
另外,有些发布者的网站将 404 Not Found 视为资源暂时不可用。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外,有些发布者的网站将 404 Not Found 视为资源暂时不可用。
这应该只是页面描述,实际应该还是响应 404。
errorMessage = $"\n[Debug] 访问 <ManifestFilePath> 中的 {url} 时超时: {e.Message}"; | ||
checkedUrls.TryAdd(url, errorMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
除了重复检查,超时也是影响检查时间的一大因素。但我们似乎只能通过忽略来处理这些超时的 URL。
也许这里存储超时结果能缓解超时 URL 带来的时间,但也许我们不该存储超时结果,因为它可能在后续缓解?
亦或者我们应该抛出 TimeoutException
让下面的 catch (TimeoutException e)
处理?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得还是保持原样,在 catch 里抛出并不会被下面的 catch 捕获。
283fed7
to
9eea193
Compare
Co-authored-by: 宁静致远 <172552290+fjwxzde@users.noreply.github.com>
我认为还是保留原样。有些 errorMessage 在失败模式 默认 和 详细 下有不同的 errorMessage。 errorMessage = $"...";
if (failureLevel == "详细")
{
errorMessage = string.Concat(errorMessage, $"[Hint] Sundry 命令: ...");
}
checkedUrls.TryAdd(url, errorMessage);
WriteErrorMessage(errorMessage, filePath);
if (failureLevel == "详细")
{
return false;
} |
此次优化重构了 URL 检查结果处理逻辑。
在第一次检查一个 URL 时,将 URL 和检查结果一起存入 checkedUrls 中;
如果后续再次检查这个 URL,则使用先前检查的结果。
对比测试: