winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ResumeFlow.cpp (1270B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #include "pch.h"
      4 #include "ResumeFlow.h"
      5 #include "winget/Reboot.h"
      6 #include <AppInstallerRuntime.h>
      7 
      8 namespace AppInstaller::CLI::Workflow
      9 {
     10     void Checkpoint::operator()(Execution::Context& context) const
     11     {
     12         if (!Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Resume))
     13         {
     14             return;
     15         }
     16 
     17         context.Checkpoint(m_checkpointName, m_contextData);
     18     }
     19 
     20     void RegisterStartupAfterReboot::operator()(Execution::Context& context) const
     21     {
     22         if (!Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Resume))
     23         {
     24             return;
     25         }
     26 
     27         if (WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::RegisterResume))
     28         {
     29             auto executablePath = AppInstaller::Runtime::GetPathTo(AppInstaller::Runtime::PathName::CLIExecutable);
     30 
     31             // RunOnce registry value must start with the full path of the executable.
     32             const auto& resumeId = context.GetResumeId();
     33             std::string commandLine = executablePath.u8string() + " resume -g " + resumeId;
     34             Reboot::WriteToRunOnceRegistry(resumeId, commandLine);
     35         }
     36     }
     37 }