Skip to content

Commit

Permalink
Fix: Fixed issue where the app didn't update after restarting when ba…
Browse files Browse the repository at this point in the history
…ckground running is on (#13339)
  • Loading branch information
hishitetsu authored Sep 6, 2023
1 parent ee85cfb commit 1250433
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ private async void Window_Closed(object sender, WindowEventArgs args)
}

if (Ioc.Default.GetRequiredService<IUserSettingsService>().GeneralSettingsService.LeaveAppRunning &&
!AppModel.ForceProcessTermination &&
!Process.GetProcessesByName("Files").Any(x => x.Id != Process.GetCurrentProcess().Id))
{
// Close open content dialogs
Expand Down
7 changes: 7 additions & 0 deletions src/Files.App/Data/Models/AppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,12 @@ public bool IsMainWindowClosed
get => isMainWindowClosed;
set => SetProperty(ref isMainWindowClosed, value);
}

private bool forceProcessTermination = false;
public bool ForceProcessTermination
{
get => forceProcessTermination;
set => SetProperty(ref forceProcessTermination, value);
}
}
}
1 change: 1 addition & 0 deletions src/Files.App/Services/SideloadUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ private async Task ApplyPackageUpdate()
try
{
var restartStatus = RegisterApplicationRestart(null, 0);
App.AppModel.ForceProcessTermination = true;

Logger?.LogInformation($"Register for restart: {restartStatus}");

Expand Down
6 changes: 5 additions & 1 deletion src/Files.App/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ public async Task CheckForUpdates()
private async Task DownloadAndInstall()
{
App.SaveSessionTabs();
App.AppModel.ForceProcessTermination = true;
var downloadOperation = _storeContext?.RequestDownloadAndInstallStorePackageUpdatesAsync(_updatePackages);
await downloadOperation.AsTask();
var result = await downloadOperation.AsTask();

if (result.OverallState == StorePackageUpdateState.Canceled)
App.AppModel.ForceProcessTermination = false;
}

private async Task GetUpdatePackages()
Expand Down

0 comments on commit 1250433

Please sign in to comment.