aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-04-25 21:52:28 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-04-25 22:58:23 -0500
commitbf31c11edf14789d22ce6542549a807d5c5ff086 (patch)
tree418678fb02026a56cd6d5e5415386177839101cb
parentd291d27f94d0702bcd4ffd6fb72125c8996b3aef (diff)
downloadwix-bf31c11edf14789d22ce6542549a807d5c5ff086.tar.gz
wix-bf31c11edf14789d22ce6542549a807d5c5ff086.tar.bz2
wix-bf31c11edf14789d22ce6542549a807d5c5ff086.zip
Add support for downloading embedded payloads.
#5253
-rw-r--r--src/engine/apply.cpp29
-rw-r--r--src/engine/container.h1
-rw-r--r--src/engine/externalengine.cpp12
-rw-r--r--src/engine/plan.cpp1
4 files changed, 21 insertions, 22 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp
index 4570ffb9..74f57f6a 100644
--- a/src/engine/apply.cpp
+++ b/src/engine/apply.cpp
@@ -1422,19 +1422,19 @@ static HRESULT AcquireContainerOrPayload(
1422 hr = CacheGetLocalSourcePaths(wzRelativePath, *pwzSourcePath, wzDestinationPath, pContext->wzLayoutDirectory, pContext->pVariables, &pContext->rgSearchPaths, &pContext->cSearchPaths, &dwChosenSearchPath, &dwDestinationSearchPath); 1422 hr = CacheGetLocalSourcePaths(wzRelativePath, *pwzSourcePath, wzDestinationPath, pContext->wzLayoutDirectory, pContext->pVariables, &pContext->rgSearchPaths, &pContext->cSearchPaths, &dwChosenSearchPath, &dwDestinationSearchPath);
1423 ExitOnFailure(hr, "Failed to search local source."); 1423 ExitOnFailure(hr, "Failed to search local source.");
1424 1424
1425 // When a payload comes from a container, the container has the highest chance of being correct.
1426 // But we want to avoid extracting the container multiple times.
1427 // So only consider the destination path, which means the container was already extracted.
1428 if (wzPayloadContainerId) 1425 if (wzPayloadContainerId)
1429 { 1426 {
1427 // When a payload comes from a container, the container has the highest chance of being correct.
1428 // But we want to avoid extracting the container multiple times.
1429 // So only consider the destination path, which means the container was already extracted.
1430 if (FileExistsEx(pContext->rgSearchPaths[dwDestinationSearchPath], NULL)) 1430 if (FileExistsEx(pContext->rgSearchPaths[dwDestinationSearchPath], NULL))
1431 { 1431 {
1432 fFoundLocal = TRUE; 1432 fFoundLocal = TRUE;
1433 dwChosenSearchPath = dwDestinationSearchPath; 1433 dwChosenSearchPath = dwDestinationSearchPath;
1434 } 1434 }
1435 else 1435 else // don't prefer the container if extracting it already failed.
1436 { 1436 {
1437 fPreferExtract = TRUE; 1437 fPreferExtract = SUCCEEDED(pPayload->pContainer->hrExtract);
1438 } 1438 }
1439 } 1439 }
1440 1440
@@ -1470,14 +1470,14 @@ static HRESULT AcquireContainerOrPayload(
1470 { 1470 {
1471 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_LOCAL; 1471 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_LOCAL;
1472 } 1472 }
1473 else if (wzPayloadContainerId)
1474 {
1475 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_CONTAINER;
1476 }
1477 else if (*pwzDownloadUrl && **pwzDownloadUrl) 1473 else if (*pwzDownloadUrl && **pwzDownloadUrl)
1478 { 1474 {
1479 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_DOWNLOAD; 1475 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_DOWNLOAD;
1480 } 1476 }
1477 else if (wzPayloadContainerId)
1478 {
1479 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_CONTAINER;
1480 }
1481 } 1481 }
1482 1482
1483 // Let the BA have a chance to override the source. 1483 // Let the BA have a chance to override the source.
@@ -1526,7 +1526,7 @@ static HRESULT AcquireContainerOrPayload(
1526 1526
1527 break; 1527 break;
1528 case BOOTSTRAPPER_CACHE_OPERATION_EXTRACT: 1528 case BOOTSTRAPPER_CACHE_OPERATION_EXTRACT:
1529 Assert(pPayload->pContainer); 1529 Assert(pPayload && pPayload->pContainer);
1530 1530
1531 hr = ApplyExtractContainer(pContext, pPayload->pContainer); 1531 hr = ApplyExtractContainer(pContext, pPayload->pContainer);
1532 ExitOnFailure(hr, "Failed to extract container for payload: %ls", wzPayloadId); 1532 ExitOnFailure(hr, "Failed to extract container for payload: %ls", wzPayloadId);
@@ -1541,6 +1541,15 @@ static HRESULT AcquireContainerOrPayload(
1541 hr = CompleteCacheProgress(pProgress, pContainer ? pContainer->qwFileSize : pPayload->qwFileSize); 1541 hr = CompleteCacheProgress(pProgress, pContainer ? pContainer->qwFileSize : pPayload->qwFileSize);
1542 1542
1543LExit: 1543LExit:
1544 if (BOOTSTRAPPER_CACHE_OPERATION_EXTRACT == cacheOperation)
1545 {
1546 if (FAILED(hr) && SUCCEEDED(pPayload->pContainer->hrExtract) &&
1547 (fFoundLocal || pPayload->downloadSource.sczUrl && *pPayload->downloadSource.sczUrl))
1548 {
1549 *pfRetry = TRUE;
1550 }
1551 pPayload->pContainer->hrExtract = hr;
1552 }
1544 UserExperienceOnCacheAcquireComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr, pfRetry); 1553 UserExperienceOnCacheAcquireComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr, pfRetry);
1545 1554
1546 pContext->cSearchPathsMax = max(pContext->cSearchPaths, pContext->cSearchPathsMax); 1555 pContext->cSearchPathsMax = max(pContext->cSearchPaths, pContext->cSearchPathsMax);
diff --git a/src/engine/container.h b/src/engine/container.h
index 3174eb38..88fe48f1 100644
--- a/src/engine/container.h
+++ b/src/engine/container.h
@@ -79,6 +79,7 @@ typedef struct _BURN_CONTAINER
79 DWORD64 qwExtractSizeTotal; 79 DWORD64 qwExtractSizeTotal;
80 DWORD64 qwCommittedCacheProgress; 80 DWORD64 qwCommittedCacheProgress;
81 DWORD64 qwCommittedExtractProgress; 81 DWORD64 qwCommittedExtractProgress;
82 HRESULT hrExtract;
82} BURN_CONTAINER; 83} BURN_CONTAINER;
83 84
84typedef struct _BURN_CONTAINERS 85typedef struct _BURN_CONTAINERS
diff --git a/src/engine/externalengine.cpp b/src/engine/externalengine.cpp
index d6c44736..63177722 100644
--- a/src/engine/externalengine.cpp
+++ b/src/engine/externalengine.cpp
@@ -357,12 +357,6 @@ HRESULT ExternalEngineSetLocalSource(
357 hr = PayloadFindById(&pEngineState->payloads, wzPayloadId, &pPayload); 357 hr = PayloadFindById(&pEngineState->payloads, wzPayloadId, &pPayload);
358 ExitOnFailure(hr, "BA requested unknown payload with id: %ls", wzPayloadId); 358 ExitOnFailure(hr, "BA requested unknown payload with id: %ls", wzPayloadId);
359 359
360 if (BURN_PAYLOAD_PACKAGING_EMBEDDED == pPayload->packaging)
361 {
362 hr = HRESULT_FROM_WIN32(ERROR_INVALID_OPERATION);
363 ExitOnFailure(hr, "BA denied while trying to set source on embedded payload: %ls", wzPayloadId);
364 }
365
366 hr = StrAllocString(&pPayload->sczSourcePath, wzPath, 0); 360 hr = StrAllocString(&pPayload->sczSourcePath, wzPath, 0);
367 ExitOnFailure(hr, "Failed to set source path for payload."); 361 ExitOnFailure(hr, "Failed to set source path for payload.");
368 } 362 }
@@ -408,12 +402,6 @@ HRESULT ExternalEngineSetDownloadSource(
408 hr = PayloadFindById(&pEngineState->payloads, wzPayloadId, &pPayload); 402 hr = PayloadFindById(&pEngineState->payloads, wzPayloadId, &pPayload);
409 ExitOnFailure(hr, "BA requested unknown payload with id: %ls", wzPayloadId); 403 ExitOnFailure(hr, "BA requested unknown payload with id: %ls", wzPayloadId);
410 404
411 if (BURN_PAYLOAD_PACKAGING_EMBEDDED == pPayload->packaging)
412 {
413 hr = HRESULT_FROM_WIN32(ERROR_INVALID_OPERATION);
414 ExitOnFailure(hr, "BA denied while trying to set download URL on embedded payload: %ls", wzPayloadId);
415 }
416
417 pDownloadSource = &pPayload->downloadSource; 405 pDownloadSource = &pPayload->downloadSource;
418 } 406 }
419 else if (wzPackageOrContainerId && *wzPackageOrContainerId) 407 else if (wzPackageOrContainerId && *wzPackageOrContainerId)
diff --git a/src/engine/plan.cpp b/src/engine/plan.cpp
index f662c445..e5c1ee36 100644
--- a/src/engine/plan.cpp
+++ b/src/engine/plan.cpp
@@ -1832,6 +1832,7 @@ static void ResetPlannedContainerState(
1832 pContainer->qwExtractSizeTotal = 0; 1832 pContainer->qwExtractSizeTotal = 0;
1833 pContainer->qwCommittedCacheProgress = 0; 1833 pContainer->qwCommittedCacheProgress = 0;
1834 pContainer->qwCommittedExtractProgress = 0; 1834 pContainer->qwCommittedExtractProgress = 0;
1835 pContainer->hrExtract = S_OK;
1835} 1836}
1836 1837
1837static void ResetPlannedPayloadsState( 1838static void ResetPlannedPayloadsState(