diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-12-15 20:02:20 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-12-15 20:06:52 -0600 |
| commit | 6ac2cf5c3dc2df77ba8be2cf12c624e1c4a20e18 (patch) | |
| tree | 8fc2c3f29078d0c0c332d6753ae148a0be5affa1 /src/engine/plan.cpp | |
| parent | fdd47bab30235f62a8bcc7a5a88c6d69267046aa (diff) | |
| download | wix-6ac2cf5c3dc2df77ba8be2cf12c624e1c4a20e18.tar.gz wix-6ac2cf5c3dc2df77ba8be2cf12c624e1c4a20e18.tar.bz2 wix-6ac2cf5c3dc2df77ba8be2cf12c624e1c4a20e18.zip | |
Refactor PlanRelatedBundlesBegin without changing behavior.
Diffstat (limited to 'src/engine/plan.cpp')
| -rw-r--r-- | src/engine/plan.cpp | 104 |
1 files changed, 61 insertions, 43 deletions
diff --git a/src/engine/plan.cpp b/src/engine/plan.cpp index 22b7033e..990ef554 100644 --- a/src/engine/plan.cpp +++ b/src/engine/plan.cpp | |||
| @@ -1211,6 +1211,65 @@ LExit: | |||
| 1211 | return hr; | 1211 | return hr; |
| 1212 | } | 1212 | } |
| 1213 | 1213 | ||
| 1214 | extern "C" HRESULT PlanDefaultRelatedBundleRequestState( | ||
| 1215 | __in BOOTSTRAPPER_RELATION_TYPE commandRelationType, | ||
| 1216 | __in BOOTSTRAPPER_RELATION_TYPE relatedBundleRelationType, | ||
| 1217 | __in BOOTSTRAPPER_ACTION action, | ||
| 1218 | __in VERUTIL_VERSION* pRegistrationVersion, | ||
| 1219 | __in VERUTIL_VERSION* pRelatedBundleVersion, | ||
| 1220 | __inout BOOTSTRAPPER_REQUEST_STATE* pRequestState | ||
| 1221 | ) | ||
| 1222 | { | ||
| 1223 | HRESULT hr = S_OK; | ||
| 1224 | int nCompareResult = 0; | ||
| 1225 | |||
| 1226 | switch (relatedBundleRelationType) | ||
| 1227 | { | ||
| 1228 | case BOOTSTRAPPER_RELATION_UPGRADE: | ||
| 1229 | if (BOOTSTRAPPER_RELATION_UPGRADE != commandRelationType && BOOTSTRAPPER_ACTION_UNINSTALL < action) | ||
| 1230 | { | ||
| 1231 | hr = VerCompareParsedVersions(pRegistrationVersion, pRelatedBundleVersion, &nCompareResult); | ||
| 1232 | ExitOnFailure(hr, "Failed to compare bundle version '%ls' to related bundle version '%ls'", pRegistrationVersion ? pRegistrationVersion->sczVersion : NULL, pRelatedBundleVersion ? pRelatedBundleVersion->sczVersion : NULL); | ||
| 1233 | |||
| 1234 | *pRequestState = (nCompareResult < 0) ? BOOTSTRAPPER_REQUEST_STATE_NONE : BOOTSTRAPPER_REQUEST_STATE_ABSENT; | ||
| 1235 | } | ||
| 1236 | break; | ||
| 1237 | case BOOTSTRAPPER_RELATION_PATCH: __fallthrough; | ||
| 1238 | case BOOTSTRAPPER_RELATION_ADDON: | ||
| 1239 | if (BOOTSTRAPPER_ACTION_UNINSTALL == action) | ||
| 1240 | { | ||
| 1241 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_ABSENT; | ||
| 1242 | } | ||
| 1243 | else if (BOOTSTRAPPER_ACTION_INSTALL == action || BOOTSTRAPPER_ACTION_MODIFY == action) | ||
| 1244 | { | ||
| 1245 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; | ||
| 1246 | } | ||
| 1247 | else if (BOOTSTRAPPER_ACTION_REPAIR == action) | ||
| 1248 | { | ||
| 1249 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_REPAIR; | ||
| 1250 | } | ||
| 1251 | break; | ||
| 1252 | case BOOTSTRAPPER_RELATION_DEPENDENT: | ||
| 1253 | // Automatically repair dependent bundles to restore missing | ||
| 1254 | // packages after uninstall unless we're being upgraded with the | ||
| 1255 | // assumption that upgrades are cumulative (as intended). | ||
| 1256 | if (BOOTSTRAPPER_RELATION_UPGRADE != commandRelationType && BOOTSTRAPPER_ACTION_UNINSTALL == action) | ||
| 1257 | { | ||
| 1258 | *pRequestState = BOOTSTRAPPER_REQUEST_STATE_REPAIR; | ||
| 1259 | } | ||
| 1260 | break; | ||
| 1261 | case BOOTSTRAPPER_RELATION_DETECT: | ||
| 1262 | break; | ||
| 1263 | default: | ||
| 1264 | hr = E_UNEXPECTED; | ||
| 1265 | ExitOnFailure(hr, "Unexpected relation type encountered during plan: %d", relatedBundleRelationType); | ||
| 1266 | break; | ||
| 1267 | } | ||
| 1268 | |||
| 1269 | LExit: | ||
| 1270 | return hr; | ||
| 1271 | } | ||
| 1272 | |||
| 1214 | extern "C" HRESULT PlanRelatedBundlesBegin( | 1273 | extern "C" HRESULT PlanRelatedBundlesBegin( |
| 1215 | __in BURN_USER_EXPERIENCE* pUserExperience, | 1274 | __in BURN_USER_EXPERIENCE* pUserExperience, |
| 1216 | __in BURN_REGISTRATION* pRegistration, | 1275 | __in BURN_REGISTRATION* pRegistration, |
| @@ -1222,7 +1281,6 @@ extern "C" HRESULT PlanRelatedBundlesBegin( | |||
| 1222 | LPWSTR* rgsczAncestors = NULL; | 1281 | LPWSTR* rgsczAncestors = NULL; |
| 1223 | UINT cAncestors = 0; | 1282 | UINT cAncestors = 0; |
| 1224 | STRINGDICT_HANDLE sdAncestors = NULL; | 1283 | STRINGDICT_HANDLE sdAncestors = NULL; |
| 1225 | int nCompareResult = 0; | ||
| 1226 | 1284 | ||
| 1227 | if (pRegistration->sczAncestors) | 1285 | if (pRegistration->sczAncestors) |
| 1228 | { | 1286 | { |
| @@ -1272,48 +1330,8 @@ extern "C" HRESULT PlanRelatedBundlesBegin( | |||
| 1272 | ExitOnFailure(hr, "Failed to copy self to related bundle ancestors."); | 1330 | ExitOnFailure(hr, "Failed to copy self to related bundle ancestors."); |
| 1273 | } | 1331 | } |
| 1274 | 1332 | ||
| 1275 | switch (pRelatedBundle->relationType) | 1333 | hr = PlanDefaultRelatedBundleRequestState(relationType, pRelatedBundle->relationType, pPlan->action, pRegistration->pVersion, pRelatedBundle->pVersion, &pRelatedBundle->package.requested); |
| 1276 | { | 1334 | ExitOnFailure(hr, "Failed to get default request state for related bundle."); |
| 1277 | case BOOTSTRAPPER_RELATION_UPGRADE: | ||
| 1278 | if (BOOTSTRAPPER_RELATION_UPGRADE != relationType && BOOTSTRAPPER_ACTION_UNINSTALL < pPlan->action) | ||
| 1279 | { | ||
| 1280 | hr = VerCompareParsedVersions(pRegistration->pVersion, pRelatedBundle->pVersion, &nCompareResult); | ||
| 1281 | ExitOnFailure(hr, "Failed to compare bundle version '%ls' to related bundle version '%ls'", pRegistration->pVersion, pRelatedBundle->pVersion); | ||
| 1282 | |||
| 1283 | pRelatedBundle->package.requested = (nCompareResult < 0) ? BOOTSTRAPPER_REQUEST_STATE_NONE : BOOTSTRAPPER_REQUEST_STATE_ABSENT; | ||
| 1284 | } | ||
| 1285 | break; | ||
| 1286 | case BOOTSTRAPPER_RELATION_PATCH: __fallthrough; | ||
| 1287 | case BOOTSTRAPPER_RELATION_ADDON: | ||
| 1288 | if (BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) | ||
| 1289 | { | ||
| 1290 | pRelatedBundle->package.requested = BOOTSTRAPPER_REQUEST_STATE_ABSENT; | ||
| 1291 | } | ||
| 1292 | else if (BOOTSTRAPPER_ACTION_INSTALL == pPlan->action || BOOTSTRAPPER_ACTION_MODIFY == pPlan->action) | ||
| 1293 | { | ||
| 1294 | pRelatedBundle->package.requested = BOOTSTRAPPER_REQUEST_STATE_PRESENT; | ||
| 1295 | } | ||
| 1296 | else if (BOOTSTRAPPER_ACTION_REPAIR == pPlan->action) | ||
| 1297 | { | ||
| 1298 | pRelatedBundle->package.requested = BOOTSTRAPPER_REQUEST_STATE_REPAIR; | ||
| 1299 | } | ||
| 1300 | break; | ||
| 1301 | case BOOTSTRAPPER_RELATION_DEPENDENT: | ||
| 1302 | // Automatically repair dependent bundles to restore missing | ||
| 1303 | // packages after uninstall unless we're being upgraded with the | ||
| 1304 | // assumption that upgrades are cumulative (as intended). | ||
| 1305 | if (BOOTSTRAPPER_RELATION_UPGRADE != relationType && BOOTSTRAPPER_ACTION_UNINSTALL == pPlan->action) | ||
| 1306 | { | ||
| 1307 | pRelatedBundle->package.requested = BOOTSTRAPPER_REQUEST_STATE_REPAIR; | ||
| 1308 | } | ||
| 1309 | break; | ||
| 1310 | case BOOTSTRAPPER_RELATION_DETECT: | ||
| 1311 | break; | ||
| 1312 | default: | ||
| 1313 | hr = E_UNEXPECTED; | ||
| 1314 | ExitOnFailure(hr, "Unexpected relation type encountered during plan: %d", pRelatedBundle->relationType); | ||
| 1315 | break; | ||
| 1316 | } | ||
| 1317 | 1335 | ||
| 1318 | pRelatedBundle->package.defaultRequested = pRelatedBundle->package.requested; | 1336 | pRelatedBundle->package.defaultRequested = pRelatedBundle->package.requested; |
| 1319 | 1337 | ||
