Skip to content

Commit

Permalink
refactor: 状态码不对会提示
Browse files Browse the repository at this point in the history
  • Loading branch information
SALTWOOD committed Jul 28, 2024
1 parent 3463372 commit bd7b35a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CSharp-OpenBMCLAPI/Modules/Cluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,13 @@ internal async Task DownloadFile(string hash, string path, bool force = false)
(resp, urls) = GetRedirectUrls(path[1..]);
if (resp == null) throw new Exception("Response is null.");
if (resp.StatusCode < HttpStatusCode.BadRequest && resp.StatusCode >= HttpStatusCode.OK)
this.storage.WriteFileStream(Utils.HashToFileName(hash), await resp.Content.ReadAsStreamAsync());
{
this.storage.WriteFileStream(Utils.HashToFileName(hash), await resp.Content.ReadAsStreamAsync());
}
else
{
throw new Exception($"Response code {resp.StatusCode}, 2xx or 3xx expected.");
}
}
catch (Exception ex)
{
Expand Down

0 comments on commit bd7b35a

Please sign in to comment.