Detect whether the bundle is cached.
Sean Hall committed
Apr 16, 2021 at 09:42 UTC
c88806b89293f5bb92c42e90230e48be6b79b7f4
9 files changed
+17
-11
src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
+1
@@ -463,6 +463,7 @@ struct BA_ONDETECTBEGIN_ARGS
463
DWORD cbSize;
464
BOOL fInstalled;
465
DWORD cPackages;
466
+ BOOL fCached;
467
};
468
469
struct BA_ONDETECTBEGIN_RESULTS
src/engine/cache.cpp
+1
@@ -733,6 +733,7 @@ extern "C" HRESULT CacheCompleteBundle(
733
hr = PathConcat(sczTargetDirectory, wzExecutableName, &sczTargetPath);
734
ExitOnFailure(hr, "Failed to combine completed path with engine file name.");
735
736
+ // We can't just use wzExecutablePath because we needed to call CreateCompletedPath to ensure that the destination was secured.
737
Assert(CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, wzExecutablePath, -1, sczTargetPath, -1));
738
739
// If the bundle is running out of the package cache then we don't need to copy it there
src/engine/core.cpp
+4
-4
@@ -239,7 +239,7 @@ extern "C" HRESULT CoreQueryRegistration(
239
SIZE_T iBuffer = 0;
240
241
// Detect if bundle is already installed.
242
- hr = RegistrationDetectInstalled(&pEngineState->registration, &pEngineState->registration.fInstalled);
242
+ hr = RegistrationDetectInstalled(&pEngineState->registration);
243
ExitOnFailure(hr, "Failed to detect bundle install state.");
244
245
// detect resume type
@@ -293,7 +293,7 @@ extern "C" HRESULT CoreDetect(
293
// only happens if Apply() changed the state of bundle (installed or
294
// uninstalled). In that case, Detect() can be used here to reset
295
// the installed state.
296
- hr = RegistrationDetectInstalled(&pEngineState->registration, &pEngineState->registration.fInstalled);
296
+ hr = RegistrationDetectInstalled(&pEngineState->registration);
297
ExitOnFailure(hr, "Failed to detect bundle install state.");
298
299
if (pEngineState->registration.fInstalled)
@@ -308,7 +308,7 @@ extern "C" HRESULT CoreDetect(
308
}
309
310
fDetectBegan = TRUE;
311
- hr = UserExperienceOnDetectBegin(&pEngineState->userExperience, pEngineState->registration.fInstalled, pEngineState->packages.cPackages);
311
+ hr = UserExperienceOnDetectBegin(&pEngineState->userExperience, pEngineState->registration.fCached, pEngineState->registration.fInstalled, pEngineState->packages.cPackages);
312
ExitOnRootFailure(hr, "UX aborted detect begin.");
313
314
pEngineState->userExperience.hwndDetect = hwndParent;
@@ -426,7 +426,7 @@ LExit:
426
427
pEngineState->userExperience.hwndDetect = NULL;
428
429
- LogId(REPORT_STANDARD, MSG_DETECT_COMPLETE, hr, !fDetectBegan ? "(failed)" : LoggingBoolToString(pEngineState->registration.fInstalled), FAILED(hr) ? "(failed)" : LoggingBoolToString(pEngineState->registration.fEligibleForCleanup));
429
+ LogId(REPORT_STANDARD, MSG_DETECT_COMPLETE, hr, !fDetectBegan ? "(failed)" : LoggingBoolToString(pEngineState->registration.fInstalled), !fDetectBegan ? "(failed)" : LoggingBoolToString(pEngineState->registration.fCached), FAILED(hr) ? "(failed)" : LoggingBoolToString(pEngineState->registration.fEligibleForCleanup));
430
431
return hr;
432
}
src/engine/detect.cpp
+1
-1
@@ -173,7 +173,7 @@ extern "C" HRESULT DetectReportRelatedBundles(
173
HRESULT hr = S_OK;
174
int nCompareResult = 0;
175
BOOTSTRAPPER_REQUEST_STATE uninstallRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE;
176
- *pfEligibleForCleanup = pRegistration->fInstalled || CacheBundleRunningFromCache();
176
+ *pfEligibleForCleanup = pRegistration->fInstalled || pRegistration->fCached;
177
178
for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle)
179
{
src/engine/engine.mc
+1
-1
@@ -300,7 +300,7 @@ MessageId=199
300
Severity=Success
301
SymbolicName=MSG_DETECT_COMPLETE
302
Language=English
303
-Detect complete, result: 0x%1!x!, installed: %2!hs!, eligible for cleanup: %3!hs!
303
+Detect complete, result: 0x%1!x!, installed: %2!hs!, cached: %3!hs!, eligible for cleanup: %4!hs!
304
.
305
306
MessageId=200
src/engine/registration.cpp
+4
-3
@@ -463,14 +463,15 @@ LExit:
463
}
464
465
extern "C" HRESULT RegistrationDetectInstalled(
466
- __in BURN_REGISTRATION* pRegistration,
467
- __out BOOL* pfInstalled
466
+ __in BURN_REGISTRATION* pRegistration
467
)
468
{
469
HRESULT hr = S_OK;
470
HKEY hkRegistration = NULL;
471
DWORD dwInstalled = 0;
472
473
+ pRegistration->fCached = FileExistsEx(pRegistration->sczCacheExecutablePath, NULL);
474
+
475
// open registration key
476
hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration);
477
if (SUCCEEDED(hr))
@@ -484,7 +485,7 @@ extern "C" HRESULT RegistrationDetectInstalled(
485
hr = S_OK;
486
}
487
487
- *pfInstalled = (1 == dwInstalled);
488
+ pRegistration->fInstalled = (1 == dwInstalled);
489
490
ReleaseRegKey(hkRegistration);
491
return hr;
src/engine/registration.h
+2
-2
@@ -92,6 +92,7 @@ typedef struct _BURN_REGISTRATION
92
BOOL fPerMachine;
93
BOOL fRegisterArp;
94
BOOL fDisableResume;
95
+ BOOL fCached;
96
BOOL fInstalled;
97
LPWSTR sczId;
98
LPWSTR sczTag;
@@ -174,8 +175,7 @@ HRESULT RegistrationSetVariables(
175
__in BURN_VARIABLES* pVariables
176
);
177
HRESULT RegistrationDetectInstalled(
177
- __in BURN_REGISTRATION* pRegistration,
178
- __out BOOL* pfInstalled
178
+ __in BURN_REGISTRATION* pRegistration
179
);
180
HRESULT RegistrationDetectResumeType(
181
__in BURN_REGISTRATION* pRegistration,
src/engine/userexperience.cpp
+2
@@ -708,6 +708,7 @@ LExit:
708
709
EXTERN_C BAAPI UserExperienceOnDetectBegin(
710
__in BURN_USER_EXPERIENCE* pUserExperience,
711
+ __in BOOL fCached,
712
__in BOOL fInstalled,
713
__in DWORD cPackages
714
)
@@ -719,6 +720,7 @@ EXTERN_C BAAPI UserExperienceOnDetectBegin(
720
args.cbSize = sizeof(args);
721
args.cPackages = cPackages;
722
args.fInstalled = fInstalled;
723
+ args.fCached = fCached;
724
725
results.cbSize = sizeof(results);
726
src/engine/userexperience.h
+1
@@ -186,6 +186,7 @@ BAAPI UserExperienceOnCommitMsiTransactionComplete(
186
);
187
BAAPI UserExperienceOnDetectBegin(
188
__in BURN_USER_EXPERIENCE* pUserExperience,
189
+ __in BOOL fCached,
190
__in BOOL fInstalled,
191
__in DWORD cPackages
192
);