diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-25 21:50:14 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-25 22:58:23 -0500 |
commit | d291d27f94d0702bcd4ffd6fb72125c8996b3aef (patch) | |
tree | 43bce4f35e93965385a9c71a8c68e7149816bc12 | |
parent | dd16dd2344ca3c750a8fc52c1e27a605fd25940d (diff) | |
download | wix-d291d27f94d0702bcd4ffd6fb72125c8996b3aef.tar.gz wix-d291d27f94d0702bcd4ffd6fb72125c8996b3aef.tar.bz2 wix-d291d27f94d0702bcd4ffd6fb72125c8996b3aef.zip |
Share code to map stream name to payload when extracting containers.
-rw-r--r-- | src/engine/apply.cpp | 21 | ||||
-rw-r--r-- | src/engine/core.cpp | 2 | ||||
-rw-r--r-- | src/engine/payload.cpp | 46 | ||||
-rw-r--r-- | src/engine/payload.h | 3 |
4 files changed, 20 insertions, 52 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp index b831be9c..4570ffb9 100644 --- a/src/engine/apply.cpp +++ b/src/engine/apply.cpp | |||
@@ -1113,7 +1113,8 @@ static HRESULT ExtractContainer( | |||
1113 | HRESULT hr = S_OK; | 1113 | HRESULT hr = S_OK; |
1114 | BURN_CONTAINER_CONTEXT context = { }; | 1114 | BURN_CONTAINER_CONTEXT context = { }; |
1115 | HANDLE hContainerHandle = INVALID_HANDLE_VALUE; | 1115 | HANDLE hContainerHandle = INVALID_HANDLE_VALUE; |
1116 | LPWSTR sczExtractPayloadId = NULL; | 1116 | LPWSTR sczStreamName = NULL; |
1117 | BURN_PAYLOAD* pExtract = NULL; | ||
1117 | BURN_CACHE_PROGRESS_CONTEXT progress = { }; | 1118 | BURN_CACHE_PROGRESS_CONTEXT progress = { }; |
1118 | 1119 | ||
1119 | progress.pCacheContext = pContext; | 1120 | progress.pCacheContext = pContext; |
@@ -1129,14 +1130,17 @@ static HRESULT ExtractContainer( | |||
1129 | hr = ContainerOpen(&context, pContainer, hContainerHandle, pContainer->sczUnverifiedPath); | 1130 | hr = ContainerOpen(&context, pContainer, hContainerHandle, pContainer->sczUnverifiedPath); |
1130 | ExitOnFailure(hr, "Failed to open container: %ls.", pContainer->sczId); | 1131 | ExitOnFailure(hr, "Failed to open container: %ls.", pContainer->sczId); |
1131 | 1132 | ||
1132 | while (S_OK == (hr = ContainerNextStream(&context, &sczExtractPayloadId))) | 1133 | while (S_OK == (hr = ContainerNextStream(&context, &sczStreamName))) |
1133 | { | 1134 | { |
1134 | BOOL fExtracted = FALSE; | 1135 | BOOL fExtracted = FALSE; |
1135 | 1136 | ||
1136 | for (DWORD iExtract = 0; iExtract < pContext->pPayloads->cPayloads; ++iExtract) | 1137 | hr = PayloadFindEmbeddedBySourcePath(pContext->pPayloads, sczStreamName, &pExtract); |
1138 | if (E_NOTFOUND != hr) | ||
1137 | { | 1139 | { |
1138 | BURN_PAYLOAD* pExtract = pContext->pPayloads->rgPayloads + iExtract; | 1140 | ExitOnFailure(hr, "Failed to find embedded payload by source path: %ls container: %ls", sczStreamName, pContainer->sczId); |
1139 | if (pExtract->sczUnverifiedPath && pExtract->cRemainingInstances && CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczExtractPayloadId, -1, pExtract->sczSourcePath, -1)) | 1141 | |
1142 | // Skip payloads that weren't planned or have already been cached. | ||
1143 | if (pExtract->sczUnverifiedPath && pExtract->cRemainingInstances) | ||
1140 | { | 1144 | { |
1141 | progress.pPayload = pExtract; | 1145 | progress.pPayload = pExtract; |
1142 | 1146 | ||
@@ -1161,17 +1165,16 @@ static HRESULT ExtractContainer( | |||
1161 | } | 1165 | } |
1162 | 1166 | ||
1163 | UserExperienceOnCachePayloadExtractComplete(pContext->pUX, pContainer->sczId, pExtract->sczKey, hr); | 1167 | UserExperienceOnCachePayloadExtractComplete(pContext->pUX, pContainer->sczId, pExtract->sczKey, hr); |
1164 | ExitOnFailure(hr, "Failed to extract payload: %ls from container: %ls", sczExtractPayloadId, pContainer->sczId); | 1168 | ExitOnFailure(hr, "Failed to extract payload: %ls from container: %ls", sczStreamName, pContainer->sczId); |
1165 | 1169 | ||
1166 | fExtracted = TRUE; | 1170 | fExtracted = TRUE; |
1167 | break; | ||
1168 | } | 1171 | } |
1169 | } | 1172 | } |
1170 | 1173 | ||
1171 | if (!fExtracted) | 1174 | if (!fExtracted) |
1172 | { | 1175 | { |
1173 | hr = ContainerSkipStream(&context); | 1176 | hr = ContainerSkipStream(&context); |
1174 | ExitOnFailure(hr, "Failed to skip the extraction of payload: %ls from container: %ls", sczExtractPayloadId, pContainer->sczId); | 1177 | ExitOnFailure(hr, "Failed to skip the extraction of payload: %ls from container: %ls", sczStreamName, pContainer->sczId); |
1175 | } | 1178 | } |
1176 | } | 1179 | } |
1177 | 1180 | ||
@@ -1182,7 +1185,7 @@ static HRESULT ExtractContainer( | |||
1182 | ExitOnFailure(hr, "Failed to extract all payloads from container: %ls", pContainer->sczId); | 1185 | ExitOnFailure(hr, "Failed to extract all payloads from container: %ls", pContainer->sczId); |
1183 | 1186 | ||
1184 | LExit: | 1187 | LExit: |
1185 | ReleaseStr(sczExtractPayloadId); | 1188 | ReleaseStr(sczStreamName); |
1186 | ContainerClose(&context); | 1189 | ContainerClose(&context); |
1187 | 1190 | ||
1188 | return hr; | 1191 | return hr; |
diff --git a/src/engine/core.cpp b/src/engine/core.cpp index aea614d2..969b94a0 100644 --- a/src/engine/core.cpp +++ b/src/engine/core.cpp | |||
@@ -155,7 +155,7 @@ extern "C" HRESULT CoreInitialize( | |||
155 | hr = UserExperienceEnsureWorkingFolder(pEngineState->registration.sczId, &pEngineState->userExperience.sczTempDirectory); | 155 | hr = UserExperienceEnsureWorkingFolder(pEngineState->registration.sczId, &pEngineState->userExperience.sczTempDirectory); |
156 | ExitOnFailure(hr, "Failed to get unique temporary folder for bootstrapper application."); | 156 | ExitOnFailure(hr, "Failed to get unique temporary folder for bootstrapper application."); |
157 | 157 | ||
158 | hr = PayloadExtractFromContainer(&pEngineState->userExperience.payloads, NULL, &containerContext, pEngineState->userExperience.sczTempDirectory); | 158 | hr = PayloadExtractUXContainer(&pEngineState->userExperience.payloads, &containerContext, pEngineState->userExperience.sczTempDirectory); |
159 | ExitOnFailure(hr, "Failed to extract bootstrapper application payloads."); | 159 | ExitOnFailure(hr, "Failed to extract bootstrapper application payloads."); |
160 | 160 | ||
161 | hr = PathConcat(pEngineState->userExperience.sczTempDirectory, L"BootstrapperApplicationData.xml", &pEngineState->command.wzBootstrapperApplicationDataPath); | 161 | hr = PathConcat(pEngineState->userExperience.sczTempDirectory, L"BootstrapperApplicationData.xml", &pEngineState->command.wzBootstrapperApplicationDataPath); |
diff --git a/src/engine/payload.cpp b/src/engine/payload.cpp index f29fa2bd..72eb3476 100644 --- a/src/engine/payload.cpp +++ b/src/engine/payload.cpp | |||
@@ -190,9 +190,8 @@ extern "C" void PayloadsUninitialize( | |||
190 | memset(pPayloads, 0, sizeof(BURN_PAYLOADS)); | 190 | memset(pPayloads, 0, sizeof(BURN_PAYLOADS)); |
191 | } | 191 | } |
192 | 192 | ||
193 | extern "C" HRESULT PayloadExtractFromContainer( | 193 | extern "C" HRESULT PayloadExtractUXContainer( |
194 | __in BURN_PAYLOADS* pPayloads, | 194 | __in BURN_PAYLOADS* pPayloads, |
195 | __in_opt BURN_CONTAINER* pContainer, | ||
196 | __in BURN_CONTAINER_CONTEXT* pContainerContext, | 195 | __in BURN_CONTAINER_CONTEXT* pContainerContext, |
197 | __in_z LPCWSTR wzTargetDir | 196 | __in_z LPCWSTR wzTargetDir |
198 | ) | 197 | ) |
@@ -215,7 +214,7 @@ extern "C" HRESULT PayloadExtractFromContainer( | |||
215 | ExitOnFailure(hr, "Failed to get next stream."); | 214 | ExitOnFailure(hr, "Failed to get next stream."); |
216 | 215 | ||
217 | // find payload by stream name | 216 | // find payload by stream name |
218 | hr = FindEmbeddedBySourcePath(pPayloads, pContainer, sczStreamName, &pPayload); | 217 | hr = PayloadFindEmbeddedBySourcePath(pPayloads, sczStreamName, &pPayload); |
219 | ExitOnFailure(hr, "Failed to find embedded payload: %ls", sczStreamName); | 218 | ExitOnFailure(hr, "Failed to find embedded payload: %ls", sczStreamName); |
220 | 219 | ||
221 | // make file path | 220 | // make file path |
@@ -241,15 +240,11 @@ extern "C" HRESULT PayloadExtractFromContainer( | |||
241 | { | 240 | { |
242 | pPayload = &pPayloads->rgPayloads[i]; | 241 | pPayload = &pPayloads->rgPayloads[i]; |
243 | 242 | ||
244 | // if the payload is part of the container | 243 | // if the payload has not been acquired |
245 | if (!pContainer || pPayload->pContainer == pContainer) | 244 | if (BURN_PAYLOAD_STATE_ACQUIRED > pPayload->state) |
246 | { | 245 | { |
247 | // if the payload has not been acquired | 246 | hr = E_INVALIDDATA; |
248 | if (BURN_PAYLOAD_STATE_ACQUIRED > pPayload->state) | 247 | ExitOnRootFailure(hr, "Payload was not found in container: %ls", pPayload->sczKey); |
249 | { | ||
250 | hr = E_INVALIDDATA; | ||
251 | ExitOnRootFailure(hr, "Payload was not found in container: %ls", pPayload->sczKey); | ||
252 | } | ||
253 | } | 248 | } |
254 | } | 249 | } |
255 | 250 | ||
@@ -317,32 +312,3 @@ LExit: | |||
317 | 312 | ||
318 | 313 | ||
319 | // internal function definitions | 314 | // internal function definitions |
320 | |||
321 | static HRESULT FindEmbeddedBySourcePath( | ||
322 | __in BURN_PAYLOADS* pPayloads, | ||
323 | __in_opt BURN_CONTAINER* pContainer, | ||
324 | __in_z LPCWSTR wzStreamName, | ||
325 | __out BURN_PAYLOAD** ppPayload | ||
326 | ) | ||
327 | { | ||
328 | HRESULT hr = S_OK; | ||
329 | |||
330 | for (DWORD i = 0; i < pPayloads->cPayloads; ++i) | ||
331 | { | ||
332 | BURN_PAYLOAD* pPayload = &pPayloads->rgPayloads[i]; | ||
333 | |||
334 | if (BURN_PAYLOAD_PACKAGING_EMBEDDED == pPayload->packaging && (!pContainer || pPayload->pContainer == pContainer)) | ||
335 | { | ||
336 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, pPayload->sczSourcePath, -1, wzStreamName, -1)) | ||
337 | { | ||
338 | *ppPayload = pPayload; | ||
339 | ExitFunction1(hr = S_OK); | ||
340 | } | ||
341 | } | ||
342 | } | ||
343 | |||
344 | hr = E_NOTFOUND; | ||
345 | |||
346 | LExit: | ||
347 | return hr; | ||
348 | } | ||
diff --git a/src/engine/payload.h b/src/engine/payload.h index ad10509d..f28b437f 100644 --- a/src/engine/payload.h +++ b/src/engine/payload.h | |||
@@ -85,9 +85,8 @@ void PayloadUninitialize( | |||
85 | void PayloadsUninitialize( | 85 | void PayloadsUninitialize( |
86 | __in BURN_PAYLOADS* pPayloads | 86 | __in BURN_PAYLOADS* pPayloads |
87 | ); | 87 | ); |
88 | HRESULT PayloadExtractFromContainer( | 88 | HRESULT PayloadExtractUXContainer( |
89 | __in BURN_PAYLOADS* pPayloads, | 89 | __in BURN_PAYLOADS* pPayloads, |
90 | __in_opt BURN_CONTAINER* pContainer, | ||
91 | __in BURN_CONTAINER_CONTEXT* pContainerContext, | 90 | __in BURN_CONTAINER_CONTEXT* pContainerContext, |
92 | __in_z LPCWSTR wzTargetDir | 91 | __in_z LPCWSTR wzTargetDir |
93 | ); | 92 | ); |