diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-02-02 16:57:33 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-02-04 22:16:10 -0600 |
| commit | 39725a1a6d1c72a6748bd3c306af32bcae6dbf8f (patch) | |
| tree | fe37f5ad08878e2f8d36c92762a784fd13c39df2 /src/engine/core.cpp | |
| parent | bb7d4bdc09d0b52a65b8cf3b5ae629f385fc8011 (diff) | |
| download | wix-39725a1a6d1c72a6748bd3c306af32bcae6dbf8f.tar.gz wix-39725a1a6d1c72a6748bd3c306af32bcae6dbf8f.tar.bz2 wix-39725a1a6d1c72a6748bd3c306af32bcae6dbf8f.zip | |
Require re-Detect after Apply.
Diffstat (limited to 'src/engine/core.cpp')
| -rw-r--r-- | src/engine/core.cpp | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/src/engine/core.cpp b/src/engine/core.cpp index a644d377..a4c118a3 100644 --- a/src/engine/core.cpp +++ b/src/engine/core.cpp | |||
| @@ -242,6 +242,13 @@ extern "C" HRESULT CoreDetect( | |||
| 242 | 242 | ||
| 243 | LogId(REPORT_STANDARD, MSG_DETECT_BEGIN, pEngineState->packages.cPackages); | 243 | LogId(REPORT_STANDARD, MSG_DETECT_BEGIN, pEngineState->packages.cPackages); |
| 244 | 244 | ||
| 245 | // Always reset the detect state which means the plan should be reset too. | ||
| 246 | pEngineState->fDetected = FALSE; | ||
| 247 | pEngineState->fPlanned = FALSE; | ||
| 248 | pEngineState->fApplied = FALSE; | ||
| 249 | DetectReset(&pEngineState->registration, &pEngineState->packages); | ||
| 250 | PlanReset(&pEngineState->plan, &pEngineState->packages); | ||
| 251 | |||
| 245 | // Detect if bundle installed state has changed since start up. This | 252 | // Detect if bundle installed state has changed since start up. This |
| 246 | // only happens if Apply() changed the state of bundle (installed or | 253 | // only happens if Apply() changed the state of bundle (installed or |
| 247 | // uninstalled). In that case, Detect() can be used here to reset | 254 | // uninstalled). In that case, Detect() can be used here to reset |
| @@ -266,10 +273,6 @@ extern "C" HRESULT CoreDetect( | |||
| 266 | 273 | ||
| 267 | pEngineState->userExperience.hwndDetect = hwndParent; | 274 | pEngineState->userExperience.hwndDetect = hwndParent; |
| 268 | 275 | ||
| 269 | // Always reset the detect state which means the plan should be reset too. | ||
| 270 | DetectReset(&pEngineState->registration, &pEngineState->packages); | ||
| 271 | PlanReset(&pEngineState->plan, &pEngineState->packages); | ||
| 272 | |||
| 273 | hr = SearchesExecute(&pEngineState->searches, &pEngineState->variables); | 276 | hr = SearchesExecute(&pEngineState->searches, &pEngineState->variables); |
| 274 | ExitOnFailure(hr, "Failed to execute searches."); | 277 | ExitOnFailure(hr, "Failed to execute searches."); |
| 275 | 278 | ||
| @@ -365,6 +368,11 @@ LExit: | |||
| 365 | hr = hrFirstPackageFailure; | 368 | hr = hrFirstPackageFailure; |
| 366 | } | 369 | } |
| 367 | 370 | ||
| 371 | if (SUCCEEDED(hr)) | ||
| 372 | { | ||
| 373 | pEngineState->fDetected = TRUE; | ||
| 374 | } | ||
| 375 | |||
| 368 | if (fDetectBegan) | 376 | if (fDetectBegan) |
| 369 | { | 377 | { |
| 370 | UserExperienceOnDetectComplete(&pEngineState->userExperience, hr); | 378 | UserExperienceOnDetectComplete(&pEngineState->userExperience, hr); |
| @@ -388,6 +396,7 @@ extern "C" HRESULT CorePlan( | |||
| 388 | HANDLE hSyncpointEvent = NULL; | 396 | HANDLE hSyncpointEvent = NULL; |
| 389 | BURN_PACKAGE* pUpgradeBundlePackage = NULL; | 397 | BURN_PACKAGE* pUpgradeBundlePackage = NULL; |
| 390 | BURN_PACKAGE* pForwardCompatibleBundlePackage = NULL; | 398 | BURN_PACKAGE* pForwardCompatibleBundlePackage = NULL; |
| 399 | BOOL fContinuePlanning = TRUE; // assume we won't skip planning due to dependencies. | ||
| 391 | 400 | ||
| 392 | LogId(REPORT_STANDARD, MSG_PLAN_BEGIN, pEngineState->packages.cPackages, LoggingBurnActionToString(action)); | 401 | LogId(REPORT_STANDARD, MSG_PLAN_BEGIN, pEngineState->packages.cPackages, LoggingBurnActionToString(action)); |
| 393 | 402 | ||
| @@ -395,7 +404,17 @@ extern "C" HRESULT CorePlan( | |||
| 395 | hr = UserExperienceOnPlanBegin(&pEngineState->userExperience, pEngineState->packages.cPackages); | 404 | hr = UserExperienceOnPlanBegin(&pEngineState->userExperience, pEngineState->packages.cPackages); |
| 396 | ExitOnRootFailure(hr, "BA aborted plan begin."); | 405 | ExitOnRootFailure(hr, "BA aborted plan begin."); |
| 397 | 406 | ||
| 407 | if (!pEngineState->fDetected) | ||
| 408 | { | ||
| 409 | ExitOnFailure(hr = E_INVALIDSTATE, "Plan cannot be done without a successful Detect."); | ||
| 410 | } | ||
| 411 | else if (pEngineState->fApplied) | ||
| 412 | { | ||
| 413 | ExitOnFailure(hr = E_INVALIDSTATE, "Plan requires a new successful Detect after calling Apply."); | ||
| 414 | } | ||
| 415 | |||
| 398 | // Always reset the plan. | 416 | // Always reset the plan. |
| 417 | pEngineState->fPlanned = FALSE; | ||
| 399 | PlanReset(&pEngineState->plan, &pEngineState->packages); | 418 | PlanReset(&pEngineState->plan, &pEngineState->packages); |
| 400 | 419 | ||
| 401 | // Remember the overall action state in the plan since it shapes the changes | 420 | // Remember the overall action state in the plan since it shapes the changes |
| @@ -447,7 +466,6 @@ extern "C" HRESULT CorePlan( | |||
| 447 | } | 466 | } |
| 448 | else // doing an action that modifies the machine state. | 467 | else // doing an action that modifies the machine state. |
| 449 | { | 468 | { |
| 450 | BOOL fContinuePlanning = TRUE; // assume we'll be able to keep planning after registration. | ||
| 451 | pEngineState->plan.fPerMachine = pEngineState->registration.fPerMachine; // default the scope of the plan to the per-machine state of the bundle. | 469 | pEngineState->plan.fPerMachine = pEngineState->registration.fPerMachine; // default the scope of the plan to the per-machine state of the bundle. |
| 452 | 470 | ||
| 453 | hr = PlanRegistration(&pEngineState->plan, &pEngineState->registration, pEngineState->command.resumeType, pEngineState->command.relationType, &fContinuePlanning); | 471 | hr = PlanRegistration(&pEngineState->plan, &pEngineState->registration, pEngineState->command.resumeType, pEngineState->command.relationType, &fContinuePlanning); |
| @@ -477,12 +495,20 @@ extern "C" HRESULT CorePlan( | |||
| 477 | hr = PlanFinalizeActions(&pEngineState->plan); | 495 | hr = PlanFinalizeActions(&pEngineState->plan); |
| 478 | ExitOnFailure(hr, "Failed to remove unnecessary actions from plan."); | 496 | ExitOnFailure(hr, "Failed to remove unnecessary actions from plan."); |
| 479 | 497 | ||
| 480 | // Finally, display all packages and related bundles in the log. | 498 | if (fContinuePlanning) |
| 481 | LogPackages(pUpgradeBundlePackage, pForwardCompatibleBundlePackage, &pEngineState->packages, &pEngineState->registration.relatedBundles, action); | 499 | { |
| 500 | // Finally, display all packages and related bundles in the log. | ||
| 501 | LogPackages(pUpgradeBundlePackage, pForwardCompatibleBundlePackage, &pEngineState->packages, &pEngineState->registration.relatedBundles, action); | ||
| 502 | } | ||
| 482 | 503 | ||
| 483 | PlanDump(&pEngineState->plan); | 504 | PlanDump(&pEngineState->plan); |
| 484 | 505 | ||
| 485 | LExit: | 506 | LExit: |
| 507 | if (SUCCEEDED(hr)) | ||
| 508 | { | ||
| 509 | pEngineState->fPlanned = TRUE; | ||
| 510 | } | ||
| 511 | |||
| 486 | if (fPlanBegan) | 512 | if (fPlanBegan) |
| 487 | { | 513 | { |
| 488 | UserExperienceOnPlanComplete(&pEngineState->userExperience, hr); | 514 | UserExperienceOnPlanComplete(&pEngineState->userExperience, hr); |
| @@ -549,6 +575,15 @@ extern "C" HRESULT CoreApply( | |||
| 549 | 575 | ||
| 550 | LogId(REPORT_STANDARD, MSG_APPLY_BEGIN); | 576 | LogId(REPORT_STANDARD, MSG_APPLY_BEGIN); |
| 551 | 577 | ||
| 578 | if (!pEngineState->fPlanned) | ||
| 579 | { | ||
| 580 | ExitOnFailure(hr = E_INVALIDSTATE, "Apply cannot be done without a successful Plan."); | ||
| 581 | } | ||
| 582 | else if (pEngineState->fApplied) | ||
| 583 | { | ||
| 584 | ExitOnFailure(hr = E_INVALIDSTATE, "Plans cannot be applied multiple times."); | ||
| 585 | } | ||
| 586 | |||
| 552 | // Ensure any previous attempts to execute are reset. | 587 | // Ensure any previous attempts to execute are reset. |
| 553 | ApplyReset(&pEngineState->userExperience, &pEngineState->packages); | 588 | ApplyReset(&pEngineState->userExperience, &pEngineState->packages); |
| 554 | 589 | ||
| @@ -564,6 +599,8 @@ extern "C" HRESULT CoreApply( | |||
| 564 | hr = UserExperienceOnApplyBegin(&pEngineState->userExperience, dwPhaseCount); | 599 | hr = UserExperienceOnApplyBegin(&pEngineState->userExperience, dwPhaseCount); |
| 565 | ExitOnRootFailure(hr, "BA aborted apply begin."); | 600 | ExitOnRootFailure(hr, "BA aborted apply begin."); |
| 566 | 601 | ||
| 602 | pEngineState->fApplied = TRUE; | ||
| 603 | |||
| 567 | // Abort if this bundle already requires a restart. | 604 | // Abort if this bundle already requires a restart. |
| 568 | if (BOOTSTRAPPER_RESUME_TYPE_REBOOT_PENDING == pEngineState->command.resumeType) | 605 | if (BOOTSTRAPPER_RESUME_TYPE_REBOOT_PENDING == pEngineState->command.resumeType) |
| 569 | { | 606 | { |
| @@ -758,6 +795,8 @@ extern "C" HRESULT CoreQuit( | |||
| 758 | 795 | ||
| 759 | LogId(REPORT_STANDARD, MSG_QUIT, nExitCode); | 796 | LogId(REPORT_STANDARD, MSG_QUIT, nExitCode); |
| 760 | 797 | ||
| 798 | pEngineState->fQuit = TRUE; | ||
| 799 | |||
| 761 | ::PostQuitMessage(nExitCode); // go bye-bye. | 800 | ::PostQuitMessage(nExitCode); // go bye-bye. |
| 762 | 801 | ||
| 763 | return hr; | 802 | return hr; |
