Skip to content

Commit

Permalink
Fix: Fixed SocketException in GitHelpers.RequireGitAuthenticationAsync (
Browse files Browse the repository at this point in the history
  • Loading branch information
hishitetsu authored and yaira2 committed Feb 21, 2024
1 parent 64ea60a commit 58ffaa4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Files.App/Utils/Git/GitHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,27 +535,27 @@ public static async Task RequireGitAuthenticationAsync()
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("User-Agent", "Files App");

HttpResponseMessage codeResponse;
JsonDocument? codeJsonContent;
try
{
codeResponse = await client.PostAsync(
var codeResponse = await client.PostAsync(
$"https://github.com/login/device/code?client_id={_clientId}&scope=repo",
new StringContent(""));
}
catch
{
await DynamicDialogFactory.GetFor_GitHubConnectionError().TryShowAsync();
return;
}

if (!codeResponse.IsSuccessStatusCode)
{
await DynamicDialogFactory.GetFor_GitHubConnectionError().TryShowAsync();
return;
}
if (!codeResponse.IsSuccessStatusCode)
{
await DynamicDialogFactory.GetFor_GitHubConnectionError().TryShowAsync();
return;
}

var codeJsonContent = await codeResponse.Content.ReadFromJsonAsync<JsonDocument>();
if (codeJsonContent is null)
codeJsonContent = await codeResponse.Content.ReadFromJsonAsync<JsonDocument>();
if (codeJsonContent is null)
{
await DynamicDialogFactory.GetFor_GitHubConnectionError().TryShowAsync();
return;
}
}
catch
{
await DynamicDialogFactory.GetFor_GitHubConnectionError().TryShowAsync();
return;
Expand Down

0 comments on commit 58ffaa4

Please sign in to comment.