Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

Commit b005760

Browse files
committed
fix: 修复 1 天后 token 失效导致无法请求
opti: Task.Run 不优雅
1 parent c3c33a7 commit b005760

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

CSharp-OpenBMCLAPI/Modules/Cluster.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public Cluster(ClusterInfo info, TokenManager token) : base()
4545
this.token.FetchToken().Wait();
4646

4747
client = HttpRequest.client;
48+
client.DefaultRequestHeaders.Authorization = new("Bearer", SharedData.Token?.Token.token);
4849

4950
this.storage = new FileStorage(SharedData.Config.clusterFileDirectory);
5051

@@ -238,13 +239,9 @@ protected async Task CheckFiles()
238239
SharedData.Logger.LogInfo("开始检查文件");
239240
var resp = await client.GetAsync("openbmclapi/files");
240241
byte[] buffer = await resp.Content.ReadAsByteArrayAsync();
241-
var decomporess = new Decompressor();
242-
Task.Run(() =>
243-
{
244-
var data = decomporess.Unwrap(buffer);
245-
buffer = new byte[data.Length];
246-
data.CopyTo(buffer);
247-
}).Wait();
242+
var decompressor = new Decompressor();
243+
var data = decompressor.Unwrap(buffer).ToArray();
244+
buffer = data;
248245

249246
string avroString = @"{""type"": ""array"",""items"": {""type"": ""record"",""name"": ""fileinfo"",""fields"": [{""name"": ""path"", ""type"": ""string""},{""name"": ""hash"", ""type"": ""string""},{""name"": ""size"", ""type"": ""long""}]}}";
250247

CSharp-OpenBMCLAPI/Modules/HttpRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static HttpRequest()
1111
BaseAddress = new Uri("https://openbmclapi.bangbang93.com/")
1212
};
1313
client.DefaultRequestHeaders.UserAgent.Add(new("openbmclapi-cluster", SharedData.Config.clusterVersion));
14-
//client.DefaultRequestHeaders.Add("Authorization", SharedData.Token?.Bearer);
14+
// client.DefaultRequestHeaders.Authorization = new("Bearer", SharedData.Token?.Token.token);
1515
}
1616
}
1717
}

0 commit comments

Comments
 (0)