Skip to content

Commit

Permalink
Fix launcher updater crashing after canceling download
Browse files Browse the repository at this point in the history
  • Loading branch information
Drombeys committed Jun 17, 2024
1 parent 2122183 commit a962832
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class UpdaterService(ILogger<UpdaterService> logger, IGitStorageApiServic

public async Task UpdaterAsync(Uri uri, string fileSavePath, CancellationToken cancellationToken = default)
{
CleanUpTempFiles(); // Delete files if user canceled download

var fileName = Path.GetFileNameWithoutExtension(fileSavePath);
var fullFileName = Path.GetFileName(fileSavePath);

Expand Down
3 changes: 2 additions & 1 deletion src/ImeSense.Launchers.Belarus.Updater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));
httpClient.DefaultRequestHeaders.Add("User-Agent", ".NET Foundation Repository Reporter");

var cancellationToken = new CancellationTokenSource();
var updaterService = new UpdaterService(factory.CreateLogger<UpdaterService>(),
new GitHubApiService(factory.CreateLogger<GitHubApiService>(), httpClient, null),
new FileDownloadManager(factory.CreateLogger<FileDownloadManager>(), httpClient));
await updaterService.UpdaterAsync(UriStorage.LauncherApiUri, fileSavePath);
await updaterService.UpdaterAsync(UriStorage.LauncherApiUri, fileSavePath, cancellationToken.Token);

logger.LogInformation($"Finish!");
Launcher.Launch(Path.Combine(DirectoryStorage.Base, FileNameStorage.SBLauncher))?.Start();
Expand Down

0 comments on commit a962832

Please sign in to comment.