Esempio n. 1
0
 protected override void OnRestoreFailed(Exception ex, UpdateInformation updateInformation)
 {
     base.OnRestoreFailed(ex, updateInformation);
     Clean().Wait();
     if (LauncherRestartManager.ShowRestoreDialog(true))
     {
         var options = CreateRestoreRestartOptions();
         if (options is null)
         {
             throw ex;
         }
         ApplicationRestartManager.RestartApplication(options);
     }
     else
     {
         LauncherRegistryHelper.WriteValue(LauncherRegistryKeys.ForceRestore, true);
         Environment.Exit(-1);
     }
 }
Esempio n. 2
0
        protected override async Task <PendingHandledResult> HandleLockedComponentsCoreAsync(
            ICollection <IComponent> pendingComponents, ILockingProcessManager lockingProcessManager,
            bool ignoreSelfLocked, CancellationToken token)
        {
            token.ThrowIfCancellationRequested();
            if (!pendingComponents.Any())
            {
                return(new PendingHandledResult(HandlePendingComponentsStatus.Handled));
            }

            Logger.Trace("Hanlde restart request due to locked files");

            var processes     = lockingProcessManager.GetProcesses().ToList();
            var isSelfLocking = lockingProcessManager.ProcessesContainsSelf();

            if (!isSelfLocking && processes.Any(x => x.ApplicationType == TaskBasedUpdater.Restart.ApplicationType.Critical))
            {
                return(new PendingHandledResult(HandlePendingComponentsStatus.Declined,
                                                "Files are locked by a system process that cannot be terminated. Please restart the system"));
            }

            using var lockingProcessManagerWithoutSelf = CreateFromProcessesWithoutSelf(processes);

            if (!isSelfLocking || ignoreSelfLocked)
            {
                var restartRequestResult =
                    LauncherRestartManager.ShowProcessKillDialog(lockingProcessManagerWithoutSelf, token);
                Logger.Trace($"Kill locking processes: {restartRequestResult}, Launcher needs restart: {false}");
                if (!restartRequestResult)
                {
                    return(new PendingHandledResult(HandlePendingComponentsStatus.Declined,
                                                    "Update aborted because locked files have not been released."));
                }

                lockingProcessManagerWithoutSelf.Shutdown();
                LockedFilesWatcher.Instance.LockedFiles.Clear();
                await UpdateAsync(pendingComponents, token).ConfigureAwait(false);

                return(LockedFilesWatcher.Instance.LockedFiles.Any()
                    ? new PendingHandledResult(HandlePendingComponentsStatus.HandledButStillPending,
                                               "Update failed because there are still locked files which have not been released.")
                    : new PendingHandledResult(HandlePendingComponentsStatus.Handled));
            }

            if (!UpdateConfiguration.Instance.SupportsRestart)
            {
                return(new PendingHandledResult(HandlePendingComponentsStatus.Declined,
                                                "Update requires a self-update which is not supported for this update configuration."));
            }

            var result = LauncherRestartManager.ShowSelfKillDialog(lockingProcessManager, token);

            Logger.Trace($"Kill locking processes: {result}, Launcher needs restart: {true}");
            if (!result)
            {
                return(new PendingHandledResult(HandlePendingComponentsStatus.Declined,
                                                "Update aborted because locked files have not been released."));
            }

            lockingProcessManagerWithoutSelf.Shutdown();
            return(new PendingHandledResult(HandlePendingComponentsStatus.Restart));
        }
Esempio n. 3
0
 protected override bool PermitElevationRequest()
 {
     return(LauncherRestartManager.ShowElevateDialog());
 }