From cb3776e5e3e075e8e4fe2ae7231ec19f3345c546 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 21 Aug 2022 23:55:26 -0400 Subject: Handle downgrade failure detection during Detect. Fixes https://github.com/wixtoolset/issues/issues/6537. --- .../WixStandardBootstrapperApplication.cpp | 44 ++++++++++++++-------- .../WixStdBaTests/BundleA/BundleA_v13.wixproj | 15 ++++++++ 2 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v13.wixproj diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp index fc262e0e..d57d78a6 100644 --- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp +++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp @@ -322,6 +322,21 @@ public: // IBootstrapperApplication // Best effort } + if (BOOTSTRAPPER_ACTION_INSTALL == m_command.action && BOOTSTRAPPER_RELATION_UPGRADE == relationType) + { + int nResult = 0; + HRESULT hr = VerCompareStringVersions(m_sczBundleVersion, wzVersion, TRUE/*fStrict*/, &nResult); + BalExitOnFailure(hr, "Failed to compare bundle version: %ls to related bundle version: %ls.", m_sczBundleVersion, wzVersion); + + if (0 > nResult) + { + m_fDowngrading = TRUE; + + BalLog(BOOTSTRAPPER_LOG_LEVEL_VERBOSE, "Related bundle version: %ls is a downgrade for bundle version: %ls.", wzVersion, m_sczBundleVersion); + } + } + + LExit: return CBalBaseBootstrapperApplication::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel); } @@ -333,6 +348,15 @@ public: // IBootstrapperApplication { HRESULT hr = S_OK; + if (m_fSuppressDowngradeFailure && m_fDowngrading) + { + SetState(WIXSTDBA_STATE_APPLIED, hrStatus); + + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Bundle downgrade was attempted but downgrade failure has been suppressed."); + + ExitFunction(); + } + // If we're not interacting with the user or we're doing a layout or we're resuming just after a force restart // then automatically start planning. BOOL fSkipToPlan = SUCCEEDED(hrStatus) && @@ -365,6 +389,7 @@ public: // IBootstrapperApplication } } + LExit: return hr; } @@ -1188,21 +1213,6 @@ public: // IBootstrapperApplication return hr; } - virtual STDMETHODIMP OnApplyDowngrade( - __in HRESULT /*hrRecommendation*/, - __in HRESULT* phrStatus - ) - { - HRESULT hr = S_OK; - - if (m_fSuppressDowngradeFailure) - { - *phrStatus = S_OK; - } - - return hr; - } - virtual STDMETHODIMP OnApplyComplete( __in HRESULT hrStatus, __in BOOTSTRAPPER_APPLY_RESTART restart, @@ -3888,7 +3898,7 @@ private: hr = ThemeShowPage(m_pTheme, dwNewPageId, SW_SHOW); if (FAILED(hr)) { - BalLogError(hr, "Failed to show page: %u", dwOldPageId); + BalLogError(hr, "Failed to show page: %u", dwNewPageId); } // On the install page set the focus to the install button or the next enabled control if install is disabled. @@ -4643,6 +4653,7 @@ public: m_sczLicenseFile = NULL; m_sczLicenseUrl = NULL; m_fSuppressDowngradeFailure = FALSE; + m_fDowngrading = FALSE; m_fSuppressRepair = FALSE; m_fSupportCacheOnly = FALSE; m_fRequestedCacheOnly = FALSE; @@ -4949,6 +4960,7 @@ private: LPWSTR m_sczLicenseFile; LPWSTR m_sczLicenseUrl; BOOL m_fSuppressDowngradeFailure; + BOOL m_fDowngrading; BOOL m_fSuppressRepair; BOOL m_fSupportCacheOnly; BOOL m_fRequestedCacheOnly; diff --git a/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v13.wixproj b/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v13.wixproj new file mode 100644 index 00000000..0aeb6157 --- /dev/null +++ b/src/test/burn/TestData/WixStdBaTests/BundleA/BundleA_v13.wixproj @@ -0,0 +1,15 @@ + + + + Bundle + {7D977157-06C9-4176-A931-AC16E18AAB51} + $(DefineConstants);Version=1.3 + WixStdBaTest1_v13 + + + + + + + + \ No newline at end of file -- cgit v1.2.3-55-g6feb