Skip to content

Commit efa4908

Browse files
committed
Change usage of Http in Updater.cs and adding ConfigureAwait(false) for await in checking update
1 parent 0c97db0 commit efa4908

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Flow.Launcher.Core/Updater.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public Updater(string gitHubRepository)
2929
GitHubRepository = gitHubRepository;
3030
}
3131

32-
public async Task UpdateApp(IPublicAPI api , bool silentUpdate = true)
32+
public async Task UpdateApp(IPublicAPI api, bool silentUpdate = true)
3333
{
3434
UpdateManager updateManager;
3535
UpdateInfo newUpdateInfo;
@@ -39,7 +39,7 @@ public async Task UpdateApp(IPublicAPI api , bool silentUpdate = true)
3939

4040
try
4141
{
42-
updateManager = await GitHubUpdateManager(GitHubRepository);
42+
updateManager = await GitHubUpdateManager(GitHubRepository).ConfigureAwait(false);
4343
}
4444
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
4545
{
@@ -50,7 +50,7 @@ public async Task UpdateApp(IPublicAPI api , bool silentUpdate = true)
5050
try
5151
{
5252
// UpdateApp CheckForUpdate will return value only if the app is squirrel installed
53-
newUpdateInfo = await updateManager.CheckForUpdate().NonNull();
53+
newUpdateInfo = await updateManager.CheckForUpdate().NonNull().ConfigureAwait(false);
5454
}
5555
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
5656
{
@@ -85,8 +85,8 @@ public async Task UpdateApp(IPublicAPI api , bool silentUpdate = true)
8585
updateManager.Dispose();
8686
return;
8787
}
88-
89-
await updateManager.ApplyReleases(newUpdateInfo);
88+
89+
await updateManager.ApplyReleases(newUpdateInfo).ConfigureAwait(false);
9090

9191
if (DataLocation.PortableDataLocationInUse())
9292
{
@@ -98,11 +98,11 @@ public async Task UpdateApp(IPublicAPI api , bool silentUpdate = true)
9898
}
9999
else
100100
{
101-
await updateManager.CreateUninstallerRegistryEntry();
101+
await updateManager.CreateUninstallerRegistryEntry().ConfigureAwait(false);
102102
}
103103

104104
var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());
105-
105+
106106
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
107107

108108
// always dispose UpdateManager
@@ -133,9 +133,9 @@ private async Task<UpdateManager> GitHubUpdateManager(string repository)
133133
var uri = new Uri(repository);
134134
var api = $"https://api.github.com/repos{uri.AbsolutePath}/releases";
135135

136-
var json = await Http.GetAsync(api);
136+
var jsonStream = await Http.GetStreamAsync(api).ConfigureAwait(false);
137137

138-
var releases = JsonConvert.DeserializeObject<List<GithubRelease>>(json);
138+
var releases = await System.Text.Json.JsonSerializer.DeserializeAsync<List<GithubRelease>>(jsonStream).ConfigureAwait(false);
139139
var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First();
140140
var latestUrl = latest.HtmlUrl.Replace("/tag/", "/download/");
141141

0 commit comments

Comments
 (0)