Skip to content

Commit

Permalink
Fix updater always returning null because of a forbidden request
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorCraft committed Jan 3, 2021
1 parent 02b6230 commit e4d2cb8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion FunctionAnalyser/CommandFilesApi/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public Updater(ILogger logger)
Client.DefaultRequestHeaders.Accept.Clear();
Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));
Client.DefaultRequestHeaders.UserAgent.TryParseAdd("request");
}

public async Task<Update> CheckForUpdate()
Expand Down Expand Up @@ -60,6 +61,7 @@ private async Task<string> GetChangelog(GitHubVersion update)
try
{
GitHubAssets changelogAssets = update.GetAssets().FirstOrDefault(a => a.GetLabel() == CHANGELOG_LABEL);
if (changelogAssets == null) return "";
using HttpResponseMessage response = await Client.GetAsync(changelogAssets.GetDownloadUrl());
if (response.IsSuccessStatusCode)
{
Expand All @@ -68,7 +70,7 @@ private async Task<string> GetChangelog(GitHubVersion update)
}
catch (HttpRequestException) { }

return null;
return "";
}

private static GitHubAssets GetFileAssets(GitHubVersion update)
Expand Down

0 comments on commit e4d2cb8

Please sign in to comment.