Skip to content

Commit

Permalink
fix: 重定向记录没有记录初始 URL
Browse files Browse the repository at this point in the history
feat: 在覆写同步线程数时警告
  • Loading branch information
SALTWOOD committed Sep 17, 2024
1 parent af8ceb9 commit cb69b31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CSharp-OpenBMCLAPI/Modules/Cluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ protected async Task CheckFiles(bool skipCheck, FileVerificationMode mode)
this.files = updatedFiles;
}

if (this.Configuration.Sync.Concurrency < requiredData.maxThreadCount)
{
Logger.Instance.LogWarn($"WARNING: 同步策略的线程数小于下载文件线程数,强制覆写线程数为 {requiredData.maxThreadCount}");
Logger.Instance.LogWarn($"WARNING: 覆写同步线程数为开发测试功能,无必要请勿使用!");
}

Console.WriteLine($"总文件大小:{Utils.GetLength(this.files.Sum(f => f.size))},总文件数:{this.files.Count}");

object countLock = new();
Expand Down Expand Up @@ -650,6 +656,7 @@ internal async Task FetchFileFromCenter(string hash, bool force = false)
internal (HttpResponseMessage?, List<string>, Exception?) GetRedirectUrls(string url)
{
var redirectUrls = new List<string>();
redirectUrls.Add(url);
HttpResponseMessage? response = null;
HttpClient requestClient = new HttpClient(new HttpClientHandler
{
Expand Down
3 changes: 2 additions & 1 deletion CSharp-OpenBMCLAPI/Modules/HttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ static HttpRequest()
BaseAddress = new Uri(ClusterRequiredData.Config.CenterServerAddress)
};
// 添加UserAgent,用于标识请求来源
string ua = $"openbmclapi-cluster/{ClusterRequiredData.Config.clusterVersion} (CSharp-OpenBMCLAPI; .NET runtime v{Environment.Version}; {Environment.OSVersion}, {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}; {System.Globalization.CultureInfo.InstalledUICulture.Name})";
//string ua = $"openbmclapi-cluster/{ClusterRequiredData.Config.clusterVersion} (CSharp-OpenBMCLAPI; .NET runtime v{Environment.Version}; {Environment.OSVersion}, {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}; {System.Globalization.CultureInfo.InstalledUICulture.Name})";
string ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0";
client.DefaultRequestHeaders.Add("User-Agent", ua);
Console.WriteLine($"User-Agent: {ua}");
}
Expand Down

0 comments on commit cb69b31

Please sign in to comment.