Skip to content

Commit 6962fe9

Browse files
Merge pull request #119 from nullinside-development-group/chore/await
chore: configureawait
2 parents f51ac90 + 9a54d4a commit 6962fe9

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/Nullinside.Api.Common/Desktop/GitHubUpdateManager.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public static class GitHubUpdateManager {
3939
using var httpClient = new HttpClient(handler);
4040
using var request = new HttpRequestMessage(HttpMethod.Get, string.Format(Constants.APP_UPDATE_API, owner, repo));
4141
request.Headers.TryAddWithoutValidation("user-agent", Constants.FAKE_USER_AGENT);
42-
HttpResponseMessage response = await httpClient.SendAsync(request);
42+
HttpResponseMessage response = await httpClient.SendAsync(request).ConfigureAwait(false);
4343
if (!response.IsSuccessStatusCode) {
4444
return null;
4545
}
4646

47-
string body = await response.Content.ReadAsStringAsync();
47+
string body = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
4848
return JsonConvert.DeserializeObject<GithubLatestReleaseJson>(body);
4949
}
5050

@@ -55,7 +55,7 @@ public static async Task PrepareUpdate() {
5555
try {
5656
// To prepare the update, we just need to back up our files
5757
string backupFolder = Path.Combine(AppContext.BaseDirectory, "..", "backup");
58-
await DeleteFolderRetry(backupFolder);
58+
await DeleteFolderRetry(backupFolder).ConfigureAwait(false);
5959

6060
Directory.CreateDirectory(backupFolder);
6161
FileSystem.CopyDirectory(AppContext.BaseDirectory, backupFolder);
@@ -94,16 +94,16 @@ public static void ExitApplicationToUpdate() {
9494
public static async Task PerformUpdateAndRestart(string owner, string repo, string installFolder, string assetName) {
9595
try {
9696
// Delete the old install folder.
97-
await DeleteFolderContentsRetry(installFolder);
97+
await DeleteFolderContentsRetry(installFolder).ConfigureAwait(false);
9898

9999
// Get the latest version of the application from GitHub.
100100
string zipLocation = Path.Combine(AppContext.BaseDirectory, assetName);
101-
GithubLatestReleaseJson? latestVersion = await GetLatestVersion(owner, repo);
101+
GithubLatestReleaseJson? latestVersion = await GetLatestVersion(owner, repo).ConfigureAwait(false);
102102
using (var client = new HttpClient()) {
103-
using HttpResponseMessage response = await client.GetAsync($"https://github.com/{owner}/{repo}/releases/download/{latestVersion?.name}/{assetName}");
104-
await using Stream streamToReadFrom = await response.Content.ReadAsStreamAsync();
103+
using HttpResponseMessage response = await client.GetAsync($"https://github.com/{owner}/{repo}/releases/download/{latestVersion?.name}/{assetName}").ConfigureAwait(false);
104+
await using Stream streamToReadFrom = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
105105
await using var fileStream = new FileStream(zipLocation, FileMode.Create);
106-
await streamToReadFrom.CopyToAsync(fileStream);
106+
await streamToReadFrom.CopyToAsync(fileStream).ConfigureAwait(false);
107107
}
108108

109109
// Extract the zip file to the installation folder.
@@ -126,7 +126,7 @@ public static async Task PerformUpdateAndRestart(string owner, string repo, stri
126126
public static async Task CleanupUpdate() {
127127
string backupFolder = Path.Combine(AppContext.BaseDirectory, "..", "backup");
128128

129-
await DeleteFolderRetry(backupFolder);
129+
await DeleteFolderRetry(backupFolder).ConfigureAwait(false);
130130
}
131131

132132
/// <summary>
@@ -141,7 +141,7 @@ await Retry.Execute(() => {
141141
}
142142

143143
return Task.FromResult(true);
144-
}, 30, waitTime: TimeSpan.FromSeconds(1));
144+
}, 30, waitTime: TimeSpan.FromSeconds(1)).ConfigureAwait(false);
145145
}
146146
catch (Exception ex) {
147147
Log.Error(ex);
@@ -168,7 +168,7 @@ await Retry.Execute(() => {
168168
}
169169

170170
return Task.FromResult(true);
171-
}, 30, waitTime: TimeSpan.FromSeconds(1));
171+
}, 30, waitTime: TimeSpan.FromSeconds(1)).ConfigureAwait(false);
172172
}
173173
catch (Exception ex) {
174174
Log.Error(ex);

0 commit comments

Comments
 (0)