@@ -113,8 +113,8 @@ tl::expected<void, UpdateError> UpdateManager::register_update(const nlohmann::j
113113 auto & state_ptr = states_[id];
114114 if (!state_ptr) {
115115 state_ptr = std::make_unique<PackageState>();
116- state_ptr->phase = UpdatePhase::None;
117- state_ptr-> status = UpdateStatusInfo{UpdateStatus::Pending, std::nullopt , std::nullopt , std::nullopt };
116+ state_ptr->status =
117+ UpdateStatusInfo{UpdateStatus::Pending, UpdatePhase::None , std::nullopt , std::nullopt , std::nullopt };
118118 }
119119 return {};
120120}
@@ -139,11 +139,11 @@ tl::expected<void, UpdateError> UpdateManager::delete_update(const std::string &
139139 it->second ->active_task .wait ();
140140 }
141141 // Mark as deleting so no new operations can start on this package
142- it->second ->phase = UpdatePhase::Deleting;
142+ it->second ->status . phase = UpdatePhase::Deleting;
143143 } else {
144144 // Create sentinel to prevent concurrent start_prepare
145145 states_[id] = std::make_unique<PackageState>();
146- states_[id]->phase = UpdatePhase::Deleting;
146+ states_[id]->status . phase = UpdatePhase::Deleting;
147147 }
148148 }
149149
@@ -157,7 +157,7 @@ tl::expected<void, UpdateError> UpdateManager::delete_update(const std::string &
157157 if (had_state) {
158158 auto it = states_.find (id);
159159 if (it != states_.end () && it->second ) {
160- it->second ->phase = UpdatePhase::Failed;
160+ it->second ->status . phase = UpdatePhase::Failed;
161161 }
162162 } else {
163163 // Remove the sentinel we created - package never had state before
@@ -203,12 +203,12 @@ tl::expected<void, UpdateError> UpdateManager::start_prepare(const std::string &
203203 state_ptr = std::make_unique<PackageState>();
204204 }
205205
206- if (state_ptr->phase == UpdatePhase::Deleting) {
206+ if (state_ptr->status . phase == UpdatePhase::Deleting) {
207207 return tl::make_unexpected (UpdateError{UpdateErrorCode::Deleting, " Package is being deleted" });
208208 }
209209
210- state_ptr->phase = UpdatePhase::Preparing;
211- state_ptr-> status = UpdateStatusInfo{UpdateStatus::Pending, std::nullopt , std::nullopt , std::nullopt };
210+ state_ptr->status =
211+ UpdateStatusInfo{UpdateStatus::Pending, UpdatePhase::Preparing , std::nullopt , std::nullopt , std::nullopt };
212212 state_ptr->active_task = std::async (std::launch::async, &UpdateManager::run_prepare, this , id);
213213 return {};
214214}
@@ -229,7 +229,7 @@ tl::expected<void, UpdateError> UpdateManager::start_execute(const std::string &
229229 }
230230
231231 auto it = states_.find (id);
232- if (it == states_.end () || !it->second || it->second ->phase != UpdatePhase::Prepared) {
232+ if (it == states_.end () || !it->second || it->second ->status . phase != UpdatePhase::Prepared) {
233233 return tl::make_unexpected (UpdateError{UpdateErrorCode::NotPrepared, " Package must be prepared before execution" });
234234 }
235235 if (is_task_active (id)) {
@@ -238,8 +238,8 @@ tl::expected<void, UpdateError> UpdateManager::start_execute(const std::string &
238238 }
239239
240240 auto & state = *it->second ;
241- state.phase = UpdatePhase::Executing;
242- state. status = UpdateStatusInfo{UpdateStatus::Pending, std::nullopt , std::nullopt , std::nullopt };
241+ state.status =
242+ UpdateStatusInfo{UpdateStatus::Pending, UpdatePhase::Executing , std::nullopt , std::nullopt , std::nullopt };
243243 state.active_task = std::async (std::launch::async, &UpdateManager::run_execute, this , id);
244244 return {};
245245}
@@ -273,12 +273,12 @@ tl::expected<void, UpdateError> UpdateManager::start_automated(const std::string
273273 state_ptr = std::make_unique<PackageState>();
274274 }
275275
276- if (state_ptr->phase == UpdatePhase::Deleting) {
276+ if (state_ptr->status . phase == UpdatePhase::Deleting) {
277277 return tl::make_unexpected (UpdateError{UpdateErrorCode::Deleting, " Package is being deleted" });
278278 }
279279
280- state_ptr->phase = UpdatePhase::Preparing;
281- state_ptr-> status = UpdateStatusInfo{UpdateStatus::Pending, std::nullopt , std::nullopt , std::nullopt };
280+ state_ptr->status =
281+ UpdateStatusInfo{UpdateStatus::Pending, UpdatePhase::Preparing , std::nullopt , std::nullopt , std::nullopt };
282282 state_ptr->active_task = std::async (std::launch::async, &UpdateManager::run_automated, this , id);
283283 return {};
284284}
@@ -321,11 +321,11 @@ void UpdateManager::run_prepare(const std::string & id) {
321321 std::lock_guard<std::mutex> lock (mutex_);
322322 if (result) {
323323 state->status .status = UpdateStatus::Completed;
324- state->phase = UpdatePhase::Prepared;
324+ state->status . phase = UpdatePhase::Prepared;
325325 } else {
326326 state->status .status = UpdateStatus::Failed;
327327 state->status .error_message = result.error ().message ;
328- state->phase = UpdatePhase::Failed;
328+ state->status . phase = UpdatePhase::Failed;
329329 }
330330 snapshot = state->status ;
331331 }
@@ -338,7 +338,7 @@ void UpdateManager::run_prepare(const std::string & id) {
338338 if (it != states_.end () && it->second ) {
339339 it->second ->status .status = UpdateStatus::Failed;
340340 it->second ->status .error_message = std::string (" Exception: " ) + e.what ();
341- it->second ->phase = UpdatePhase::Failed;
341+ it->second ->status . phase = UpdatePhase::Failed;
342342 snapshot = it->second ->status ;
343343 }
344344 }
@@ -351,7 +351,7 @@ void UpdateManager::run_prepare(const std::string & id) {
351351 if (it != states_.end () && it->second ) {
352352 it->second ->status .status = UpdateStatus::Failed;
353353 it->second ->status .error_message = " Unknown exception during prepare" ;
354- it->second ->phase = UpdatePhase::Failed;
354+ it->second ->status . phase = UpdatePhase::Failed;
355355 snapshot = it->second ->status ;
356356 }
357357 }
@@ -377,11 +377,11 @@ void UpdateManager::run_execute(const std::string & id) {
377377 std::lock_guard<std::mutex> lock (mutex_);
378378 if (result) {
379379 state->status .status = UpdateStatus::Completed;
380- state->phase = UpdatePhase::Executed;
380+ state->status . phase = UpdatePhase::Executed;
381381 } else {
382382 state->status .status = UpdateStatus::Failed;
383383 state->status .error_message = result.error ().message ;
384- state->phase = UpdatePhase::Failed;
384+ state->status . phase = UpdatePhase::Failed;
385385 }
386386 snapshot = state->status ;
387387 }
@@ -394,7 +394,7 @@ void UpdateManager::run_execute(const std::string & id) {
394394 if (it != states_.end () && it->second ) {
395395 it->second ->status .status = UpdateStatus::Failed;
396396 it->second ->status .error_message = std::string (" Exception: " ) + e.what ();
397- it->second ->phase = UpdatePhase::Failed;
397+ it->second ->status . phase = UpdatePhase::Failed;
398398 snapshot = it->second ->status ;
399399 }
400400 }
@@ -407,7 +407,7 @@ void UpdateManager::run_execute(const std::string & id) {
407407 if (it != states_.end () && it->second ) {
408408 it->second ->status .status = UpdateStatus::Failed;
409409 it->second ->status .error_message = " Unknown exception during execute" ;
410- it->second ->phase = UpdatePhase::Failed;
410+ it->second ->status . phase = UpdatePhase::Failed;
411411 snapshot = it->second ->status ;
412412 }
413413 }
@@ -435,7 +435,7 @@ void UpdateManager::run_automated(const std::string & id) {
435435 std::lock_guard<std::mutex> lock (mutex_);
436436 state->status .status = UpdateStatus::Failed;
437437 state->status .error_message = prep_result.error ().message ;
438- state->phase = UpdatePhase::Failed;
438+ state->status . phase = UpdatePhase::Failed;
439439 snapshot = state->status ;
440440 }
441441 notify_status_change (id, snapshot);
@@ -445,7 +445,7 @@ void UpdateManager::run_automated(const std::string & id) {
445445 // Phase 2: Execute (reset progress for execute phase)
446446 {
447447 std::lock_guard<std::mutex> lock (mutex_);
448- state->phase = UpdatePhase::Executing;
448+ state->status . phase = UpdatePhase::Executing;
449449 state->status .progress = std::nullopt ;
450450 state->status .sub_progress = std::nullopt ;
451451 }
@@ -457,11 +457,11 @@ void UpdateManager::run_automated(const std::string & id) {
457457 std::lock_guard<std::mutex> lock (mutex_);
458458 if (exec_result) {
459459 state->status .status = UpdateStatus::Completed;
460- state->phase = UpdatePhase::Executed;
460+ state->status . phase = UpdatePhase::Executed;
461461 } else {
462462 state->status .status = UpdateStatus::Failed;
463463 state->status .error_message = exec_result.error ().message ;
464- state->phase = UpdatePhase::Failed;
464+ state->status . phase = UpdatePhase::Failed;
465465 }
466466 snapshot = state->status ;
467467 }
@@ -474,7 +474,7 @@ void UpdateManager::run_automated(const std::string & id) {
474474 if (it != states_.end () && it->second ) {
475475 it->second ->status .status = UpdateStatus::Failed;
476476 it->second ->status .error_message = std::string (" Exception: " ) + e.what ();
477- it->second ->phase = UpdatePhase::Failed;
477+ it->second ->status . phase = UpdatePhase::Failed;
478478 snapshot = it->second ->status ;
479479 }
480480 }
@@ -487,7 +487,7 @@ void UpdateManager::run_automated(const std::string & id) {
487487 if (it != states_.end () && it->second ) {
488488 it->second ->status .status = UpdateStatus::Failed;
489489 it->second ->status .error_message = " Unknown exception during automated update" ;
490- it->second ->phase = UpdatePhase::Failed;
490+ it->second ->status . phase = UpdatePhase::Failed;
491491 snapshot = it->second ->status ;
492492 }
493493 }
0 commit comments