Skip to content

Commit

Permalink
Allow cancellation token to be null in invalidate cmd
Browse files Browse the repository at this point in the history
The invalidatedircache command should not be cancelled, so we don't need
to pass a CancellationToken to it. However, the httpClient.GetAsync
overload that expects a token does not allow passing null, so we have to
use a different overload if there is no token.
  • Loading branch information
rmunn committed May 9, 2024
1 parent 87582d0 commit 368d500
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/LexBoxApi/Services/HgService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,13 @@ public async Task InvalidateDirCache(string code)
return int.TryParse(str, out int result) ? result : null;
}

private async Task<HttpContent> ExecuteHgCommandServerCommand(string code, string command, CancellationToken token)
private async Task<HttpContent> ExecuteHgCommandServerCommand(string code, string command, CancellationToken? token)
{
var httpClient = _hgClient.Value;
var baseUri = _options.Value.HgCommandServer;
var response = await httpClient.GetAsync($"{baseUri}{code}/{command}", HttpCompletionOption.ResponseHeadersRead, token);
var response = token == null
? await httpClient.GetAsync($"{baseUri}{code}/{command}", HttpCompletionOption.ResponseHeadersRead)
: await httpClient.GetAsync($"{baseUri}{code}/{command}", HttpCompletionOption.ResponseHeadersRead, token.Value);
response.EnsureSuccessStatusCode();
return response.Content;
}
Expand Down

0 comments on commit 368d500

Please sign in to comment.