diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-25 22:44:23 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-25 22:58:23 -0500 |
| commit | 14cdda3c489d6b9801f05939044e67b13939b42d (patch) | |
| tree | 7a1f1b6291af5327db56200660c350cb2047a25a /src | |
| parent | bf31c11edf14789d22ce6542549a807d5c5ff086 (diff) | |
| download | wix-14cdda3c489d6b9801f05939044e67b13939b42d.tar.gz wix-14cdda3c489d6b9801f05939044e67b13939b42d.tar.bz2 wix-14cdda3c489d6b9801f05939044e67b13939b42d.zip | |
Set source of attached containers to WixBundleOriginalSource if set.
Use file size when probing local files.
#5586
Diffstat (limited to 'src')
| -rw-r--r-- | src/engine/apply.cpp | 50 | ||||
| -rw-r--r-- | src/engine/engine.cpp | 27 |
2 files changed, 72 insertions, 5 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp index 74f57f6a..58d41b28 100644 --- a/src/engine/apply.cpp +++ b/src/engine/apply.cpp | |||
| @@ -133,6 +133,11 @@ static HRESULT AcquireContainerOrPayload( | |||
| 133 | __in BURN_CACHE_PROGRESS_CONTEXT* pProgress, | 133 | __in BURN_CACHE_PROGRESS_CONTEXT* pProgress, |
| 134 | __out BOOL* pfRetry | 134 | __out BOOL* pfRetry |
| 135 | ); | 135 | ); |
| 136 | static BOOL IsValidLocalFile( | ||
| 137 | __in_z LPCWSTR wzFilePath, | ||
| 138 | __in DWORD64 qwFileSize, | ||
| 139 | __in BOOL fMinimumFileSize | ||
| 140 | ); | ||
| 136 | static HRESULT LayoutOrCacheContainerOrPayload( | 141 | static HRESULT LayoutOrCacheContainerOrPayload( |
| 137 | __in BURN_CACHE_CONTEXT* pContext, | 142 | __in BURN_CACHE_CONTEXT* pContext, |
| 138 | __in_opt BURN_CONTAINER* pContainer, | 143 | __in_opt BURN_CONTAINER* pContainer, |
| @@ -1399,6 +1404,25 @@ static HRESULT AcquireContainerOrPayload( | |||
| 1399 | LPWSTR* pwzSourcePath = pContainer ? &pContainer->sczSourcePath : &pPayload->sczSourcePath; | 1404 | LPWSTR* pwzSourcePath = pContainer ? &pContainer->sczSourcePath : &pPayload->sczSourcePath; |
| 1400 | BOOL fFoundLocal = FALSE; | 1405 | BOOL fFoundLocal = FALSE; |
| 1401 | BOOL fPreferExtract = FALSE; | 1406 | BOOL fPreferExtract = FALSE; |
| 1407 | DWORD64 qwFileSize = 0; | ||
| 1408 | BOOL fMinimumFileSize = FALSE; | ||
| 1409 | |||
| 1410 | if (pContainer) | ||
| 1411 | { | ||
| 1412 | if (pContainer->fAttached) | ||
| 1413 | { | ||
| 1414 | fMinimumFileSize = TRUE; | ||
| 1415 | qwFileSize = pContainer->qwAttachedOffset + pContainer->qwFileSize; | ||
| 1416 | } | ||
| 1417 | else if (pContainer->pbHash && pContext->wzLayoutDirectory) | ||
| 1418 | { | ||
| 1419 | qwFileSize = pContainer->qwFileSize; | ||
| 1420 | } | ||
| 1421 | } | ||
| 1422 | else if (pPayload->pbHash) | ||
| 1423 | { | ||
| 1424 | qwFileSize = pPayload->qwFileSize; | ||
| 1425 | } | ||
| 1402 | 1426 | ||
| 1403 | pContext->cSearchPaths = 0; | 1427 | pContext->cSearchPaths = 0; |
| 1404 | *pfRetry = FALSE; | 1428 | *pfRetry = FALSE; |
| @@ -1427,7 +1451,7 @@ static HRESULT AcquireContainerOrPayload( | |||
| 1427 | // When a payload comes from a container, the container has the highest chance of being correct. | 1451 | // 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. | 1452 | // But we want to avoid extracting the container multiple times. |
| 1429 | // So only consider the destination path, which means the container was already extracted. | 1453 | // So only consider the destination path, which means the container was already extracted. |
| 1430 | if (FileExistsEx(pContext->rgSearchPaths[dwDestinationSearchPath], NULL)) | 1454 | if (IsValidLocalFile(pContext->rgSearchPaths[dwDestinationSearchPath], qwFileSize, fMinimumFileSize)) |
| 1431 | { | 1455 | { |
| 1432 | fFoundLocal = TRUE; | 1456 | fFoundLocal = TRUE; |
| 1433 | dwChosenSearchPath = dwDestinationSearchPath; | 1457 | dwChosenSearchPath = dwDestinationSearchPath; |
| @@ -1442,8 +1466,8 @@ static HRESULT AcquireContainerOrPayload( | |||
| 1442 | { | 1466 | { |
| 1443 | for (DWORD i = 0; i < pContext->cSearchPaths; ++i) | 1467 | for (DWORD i = 0; i < pContext->cSearchPaths; ++i) |
| 1444 | { | 1468 | { |
| 1445 | // If the file exists locally, choose it. | 1469 | // If the file exists locally with the correct size, choose it. |
| 1446 | if (FileExistsEx(pContext->rgSearchPaths[i], NULL)) | 1470 | if (IsValidLocalFile(pContext->rgSearchPaths[i], qwFileSize, fMinimumFileSize)) |
| 1447 | { | 1471 | { |
| 1448 | dwChosenSearchPath = i; | 1472 | dwChosenSearchPath = i; |
| 1449 | 1473 | ||
| @@ -1557,6 +1581,26 @@ LExit: | |||
| 1557 | return hr; | 1581 | return hr; |
| 1558 | } | 1582 | } |
| 1559 | 1583 | ||
| 1584 | static BOOL IsValidLocalFile( | ||
| 1585 | __in_z LPCWSTR wzFilePath, | ||
| 1586 | __in DWORD64 qwFileSize, | ||
| 1587 | __in BOOL fMinimumFileSize | ||
| 1588 | ) | ||
| 1589 | { | ||
| 1590 | LONGLONG llFileSize = 0; | ||
| 1591 | |||
| 1592 | if (!qwFileSize) | ||
| 1593 | { | ||
| 1594 | return FileExistsEx(wzFilePath, NULL); | ||
| 1595 | } | ||
| 1596 | else | ||
| 1597 | { | ||
| 1598 | return SUCCEEDED(FileSize(wzFilePath, &llFileSize)) && | ||
| 1599 | (static_cast<DWORD64>(llFileSize) == qwFileSize || | ||
| 1600 | fMinimumFileSize && static_cast<DWORD64>(llFileSize) > qwFileSize); | ||
| 1601 | } | ||
| 1602 | } | ||
| 1603 | |||
| 1560 | static HRESULT LayoutOrCacheContainerOrPayload( | 1604 | static HRESULT LayoutOrCacheContainerOrPayload( |
| 1561 | __in BURN_CACHE_CONTEXT* pContext, | 1605 | __in BURN_CACHE_CONTEXT* pContext, |
| 1562 | __in_opt BURN_CONTAINER* pContainer, | 1606 | __in_opt BURN_CONTAINER* pContainer, |
diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index bb4061a7..e2728d7f 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp | |||
| @@ -523,7 +523,8 @@ static HRESULT RunNormal( | |||
| 523 | ) | 523 | ) |
| 524 | { | 524 | { |
| 525 | HRESULT hr = S_OK; | 525 | HRESULT hr = S_OK; |
| 526 | HANDLE hPipesCreatedEvent = NULL; | 526 | LPWSTR sczOriginalSource = NULL; |
| 527 | LPWSTR sczCopiedOriginalSource = NULL; | ||
| 527 | BOOL fContinueExecution = TRUE; | 528 | BOOL fContinueExecution = TRUE; |
| 528 | BOOL fReloadApp = FALSE; | 529 | BOOL fReloadApp = FALSE; |
| 529 | BOOL fSkipCleanup = FALSE; | 530 | BOOL fSkipCleanup = FALSE; |
| @@ -558,6 +559,27 @@ static HRESULT RunNormal( | |||
| 558 | hr = CoreQueryRegistration(pEngineState); | 559 | hr = CoreQueryRegistration(pEngineState); |
| 559 | ExitOnFailure(hr, "Failed to query registration."); | 560 | ExitOnFailure(hr, "Failed to query registration."); |
| 560 | 561 | ||
| 562 | // Best effort to set the source of attached containers to BURN_BUNDLE_ORIGINAL_SOURCE. | ||
| 563 | hr = VariableGetString(&pEngineState->variables, BURN_BUNDLE_ORIGINAL_SOURCE, &sczOriginalSource); | ||
| 564 | if (SUCCEEDED(hr)) | ||
| 565 | { | ||
| 566 | for (DWORD i = 0; i < pEngineState->containers.cContainers; ++i) | ||
| 567 | { | ||
| 568 | BURN_CONTAINER* pContainer = pEngineState->containers.rgContainers + i; | ||
| 569 | if (pContainer->fAttached) | ||
| 570 | { | ||
| 571 | hr = StrAllocString(&sczCopiedOriginalSource, sczOriginalSource, 0); | ||
| 572 | if (SUCCEEDED(hr)) | ||
| 573 | { | ||
| 574 | ReleaseNullStr(pContainer->sczSourcePath); | ||
| 575 | pContainer->sczSourcePath = sczCopiedOriginalSource; | ||
| 576 | sczCopiedOriginalSource = NULL; | ||
| 577 | } | ||
| 578 | } | ||
| 579 | } | ||
| 580 | } | ||
| 581 | hr = S_OK; | ||
| 582 | |||
| 561 | // Set some built-in variables before loading the BA. | 583 | // Set some built-in variables before loading the BA. |
| 562 | hr = PlanSetVariables(pEngineState->command.action, &pEngineState->variables); | 584 | hr = PlanSetVariables(pEngineState->command.action, &pEngineState->variables); |
| 563 | ExitOnFailure(hr, "Failed to set action variables."); | 585 | ExitOnFailure(hr, "Failed to set action variables."); |
| @@ -613,7 +635,8 @@ LExit: | |||
| 613 | ::PostMessageW(pEngineState->command.hwndSplashScreen, WM_CLOSE, 0, 0); | 635 | ::PostMessageW(pEngineState->command.hwndSplashScreen, WM_CLOSE, 0, 0); |
| 614 | } | 636 | } |
| 615 | 637 | ||
| 616 | ReleaseHandle(hPipesCreatedEvent); | 638 | ReleaseStr(sczOriginalSource); |
| 639 | ReleaseStr(sczCopiedOriginalSource); | ||
| 617 | 640 | ||
| 618 | return hr; | 641 | return hr; |
| 619 | } | 642 | } |
