Skip to content

Commit d4b479e

Browse files
authored
Feature: Restart after applying update (#11191)
1 parent 58a80d0 commit d4b479e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Files.App/ServicesImplementation/SideloadUpdateService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Diagnostics;
99
using System.IO;
1010
using System.Net.Http;
11+
using System.Runtime.InteropServices;
1112
using System.Threading;
1213
using System.Threading.Tasks;
1314
using System.Xml.Serialization;
@@ -19,6 +20,9 @@ namespace Files.App.ServicesImplementation
1920
{
2021
public sealed class SideloadUpdateService : ObservableObject, IUpdateService, IDisposable
2122
{
23+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
24+
private static extern uint RegisterApplicationRestart(string pwzCommandLine, int dwFlags);
25+
2226
private const string SIDELOAD_STABLE = "https://cdn.files.community/files/stable/Files.Package.appinstaller";
2327
private const string SIDELOAD_PREVIEW = "https://cdn.files.community/files/preview/Files.Package.appinstaller";
2428

@@ -185,14 +189,18 @@ private async Task ApplyPackageUpdate()
185189

186190
try
187191
{
192+
var restartStatus = RegisterApplicationRestart(null, 0);
193+
194+
Logger?.Info($"Register for restart: {restartStatus}");
195+
188196
await Task.Run(async () =>
189197
{
190198
var bundlePath = new Uri(ApplicationData.Current.LocalFolder.Path + "\\" + TEMPORARY_UPDATE_PACKAGE_NAME);
191199

192200
var deployment = pm.RequestAddPackageAsync(
193201
bundlePath,
194202
null,
195-
DeploymentOptions.ForceTargetApplicationShutdown,
203+
DeploymentOptions.ForceApplicationShutdown,
196204
pm.GetDefaultPackageVolume(),
197205
null,
198206
null);

0 commit comments

Comments
 (0)