Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Files.App/ServicesImplementation/SideloadUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Serialization;
Expand All @@ -19,6 +20,9 @@ namespace Files.App.ServicesImplementation
{
public sealed class SideloadUpdateService : ObservableObject, IUpdateService, IDisposable
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern uint RegisterApplicationRestart(string pwzCommandLine, int dwFlags);

private const string SIDELOAD_STABLE = "https://cdn.files.community/files/stable/Files.Package.appinstaller";
private const string SIDELOAD_PREVIEW = "https://cdn.files.community/files/preview/Files.Package.appinstaller";

Expand Down Expand Up @@ -185,14 +189,18 @@ private async Task ApplyPackageUpdate()

try
{
var restartStatus = RegisterApplicationRestart(null, 0);

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

await Task.Run(async () =>
{
var bundlePath = new Uri(ApplicationData.Current.LocalFolder.Path + "\\" + TEMPORARY_UPDATE_PACKAGE_NAME);

var deployment = pm.RequestAddPackageAsync(
bundlePath,
null,
DeploymentOptions.ForceTargetApplicationShutdown,
DeploymentOptions.ForceApplicationShutdown,
pm.GetDefaultPackageVolume(),
null,
null);
Expand Down