@@ -59,6 +59,13 @@ namespace AppInstaller::CLI::Execution
5959 }
6060 }
6161
62+ void ContextOrchestrator::RequeueItem (OrchestratorQueueItem& item)
63+ {
64+ std::lock_guard<std::mutex> lockQueue{ m_queueLock };
65+
66+ item.SetState (OrchestratorQueueItemState::Queued);
67+ }
68+
6269 void ContextOrchestrator::EnqueueAndRunItem (std::shared_ptr<OrchestratorQueueItem> item)
6370 {
6471 EnqueueItem (item);
@@ -101,11 +108,10 @@ namespace AppInstaller::CLI::Execution
101108 HRESULT terminationHR = S_OK ;
102109 try
103110 {
104- ::AppInstaller:: CLI ::RootCommand rootCommand ;
111+ std::unique_ptr<Command> command = item-> PopNextCommand () ;
105112
106113 std::unique_ptr<AppInstaller::ThreadLocalStorage::PreviousThreadGlobals> setThreadGlobalsToPreviousState = item->GetContext ().GetThreadGlobals ().SetForCurrentThread ();
107114
108- std::unique_ptr<::AppInstaller::CLI ::Command> command = std::make_unique<::AppInstaller::CLI ::COMInstallCommand>(rootCommand.Name ());
109115 item->GetContext ().GetThreadGlobals ().GetTelemetryLogger ().LogCommand (command->FullName ());
110116 command->ValidateArguments (item->GetContext ().Args );
111117
@@ -123,7 +129,16 @@ namespace AppInstaller::CLI::Execution
123129 item->GetContext ().SetTerminationHR (terminationHR);
124130 }
125131
126- RemoveItemInState (*item, OrchestratorQueueItemState::Running);
132+ item->GetContext ().EnableCtrlHandler (false );
133+
134+ if (FAILED (terminationHR) || item->IsComplete ())
135+ {
136+ RemoveItemInState (*item, OrchestratorQueueItemState::Running);
137+ }
138+ else
139+ {
140+ RequeueItem (*item);
141+ }
127142
128143 item = GetNextItem ();
129144 }
@@ -180,7 +195,10 @@ namespace AppInstaller::CLI::Execution
180195
181196 std::unique_ptr<OrchestratorQueueItem> OrchestratorQueueItemFactory::CreateItemForInstall (std::wstring packageId, std::wstring sourceId, std::unique_ptr<COMContext> context)
182197 {
183- return std::make_unique<OrchestratorQueueItem>(OrchestratorQueueItemId (std::move (packageId), std::move (sourceId)), std::move (context));
198+ std::unique_ptr<OrchestratorQueueItem> item = std::make_unique<OrchestratorQueueItem>(OrchestratorQueueItemId (std::move (packageId), std::move (sourceId)), std::move (context));
199+ item->AddCommand (std::make_unique<::AppInstaller::CLI ::COMDownloadCommand>(RootCommand::CommandName));
200+ item->AddCommand (std::make_unique<::AppInstaller::CLI ::COMInstallCommand>(RootCommand::CommandName));
201+ return item;
184202 }
185203
186204}
0 commit comments