aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-04-25 21:44:40 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-04-25 22:58:23 -0500
commit666196071cf29d9b489e598a604ae0998c98b6de (patch)
tree99beb1896ca9b609120697031f845ed58ffda679
parent61a8d39f689222faa677e4bd79475cd77795c57a (diff)
downloadwix-666196071cf29d9b489e598a604ae0998c98b6de.tar.gz
wix-666196071cf29d9b489e598a604ae0998c98b6de.tar.bz2
wix-666196071cf29d9b489e598a604ae0998c98b6de.zip
For payloads in a container, prefer the container over local paths.
Still consider the destination path to avoid extracting the container for every payload. #3640
-rw-r--r--src/engine/apply.cpp45
-rw-r--r--src/engine/cache.cpp6
-rw-r--r--src/engine/cache.h3
3 files changed, 43 insertions, 11 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp
index 9cba0483..b831be9c 100644
--- a/src/engine/apply.cpp
+++ b/src/engine/apply.cpp
@@ -1359,8 +1359,8 @@ static HRESULT ApplyAcquireContainerOrPayload(
1359 1359
1360 if (fRetry) 1360 if (fRetry)
1361 { 1361 {
1362 hr = S_OK;
1363 LogErrorId(hr, pContainer ? MSG_APPLY_RETRYING_ACQUIRE_CONTAINER : MSG_APPLY_RETRYING_ACQUIRE_PAYLOAD, pContainer ? pContainer->sczId : pPayloadGroupItem->pPayload->sczKey, NULL, NULL); 1362 LogErrorId(hr, pContainer ? MSG_APPLY_RETRYING_ACQUIRE_CONTAINER : MSG_APPLY_RETRYING_ACQUIRE_PAYLOAD, pContainer ? pContainer->sczId : pPayloadGroupItem->pPayload->sczKey, NULL, NULL);
1363 hr = S_OK;
1364 } 1364 }
1365 1365
1366 ExitOnFailure(hr, "Failed to acquire %hs: %ls", pContainer ? "container" : "payload", pContainer ? pContainer->sczId : pPayloadGroupItem->pPayload->sczKey); 1366 ExitOnFailure(hr, "Failed to acquire %hs: %ls", pContainer ? "container" : "payload", pContainer ? pContainer->sczId : pPayloadGroupItem->pPayload->sczKey);
@@ -1389,11 +1389,13 @@ static HRESULT AcquireContainerOrPayload(
1389 LPCWSTR wzDestinationPath = pContainer ? pContainer->sczUnverifiedPath: pPayload->sczUnverifiedPath; 1389 LPCWSTR wzDestinationPath = pContainer ? pContainer->sczUnverifiedPath: pPayload->sczUnverifiedPath;
1390 LPCWSTR wzRelativePath = pContainer ? pContainer->sczFilePath : pPayload->sczFilePath; 1390 LPCWSTR wzRelativePath = pContainer ? pContainer->sczFilePath : pPayload->sczFilePath;
1391 DWORD dwChosenSearchPath = 0; 1391 DWORD dwChosenSearchPath = 0;
1392 DWORD dwDestinationSearchPath = 0;
1392 BOOTSTRAPPER_CACHE_OPERATION cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE; 1393 BOOTSTRAPPER_CACHE_OPERATION cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE;
1393 BOOTSTRAPPER_CACHE_RESOLVE_OPERATION resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_NONE; 1394 BOOTSTRAPPER_CACHE_RESOLVE_OPERATION resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_NONE;
1394 LPWSTR* pwzDownloadUrl = pContainer ? &pContainer->downloadSource.sczUrl : &pPayload->downloadSource.sczUrl; 1395 LPWSTR* pwzDownloadUrl = pContainer ? &pContainer->downloadSource.sczUrl : &pPayload->downloadSource.sczUrl;
1395 LPWSTR* pwzSourcePath = pContainer ? &pContainer->sczSourcePath : &pPayload->sczSourcePath; 1396 LPWSTR* pwzSourcePath = pContainer ? &pContainer->sczSourcePath : &pPayload->sczSourcePath;
1396 BOOL fFoundLocal = FALSE; 1397 BOOL fFoundLocal = FALSE;
1398 BOOL fPreferExtract = FALSE;
1397 1399
1398 pContext->cSearchPaths = 0; 1400 pContext->cSearchPaths = 0;
1399 *pfRetry = FALSE; 1401 *pfRetry = FALSE;
@@ -1409,21 +1411,42 @@ static HRESULT AcquireContainerOrPayload(
1409 do 1411 do
1410 { 1412 {
1411 fFoundLocal = FALSE; 1413 fFoundLocal = FALSE;
1414 fPreferExtract = FALSE;
1412 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_NONE; 1415 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_NONE;
1413 dwChosenSearchPath = 0; 1416 dwChosenSearchPath = 0;
1417 dwDestinationSearchPath = 0;
1414 1418
1415 hr = CacheGetLocalSourcePaths(wzRelativePath, *pwzSourcePath, wzDestinationPath, pContext->wzLayoutDirectory, pContext->pVariables, &pContext->rgSearchPaths, &pContext->cSearchPaths, &dwChosenSearchPath); 1419 hr = CacheGetLocalSourcePaths(wzRelativePath, *pwzSourcePath, wzDestinationPath, pContext->wzLayoutDirectory, pContext->pVariables, &pContext->rgSearchPaths, &pContext->cSearchPaths, &dwChosenSearchPath, &dwDestinationSearchPath);
1416 ExitOnFailure(hr, "Failed to search local source."); 1420 ExitOnFailure(hr, "Failed to search local source.");
1417 1421
1418 for (DWORD i = 0; i < pContext->cSearchPaths; ++i) 1422 // When a payload comes from a container, the container has the highest chance of being correct.
1423 // But we want to avoid extracting the container multiple times.
1424 // So only consider the destination path, which means the container was already extracted.
1425 if (wzPayloadContainerId)
1419 { 1426 {
1420 // If the file exists locally, choose it. 1427 if (FileExistsEx(pContext->rgSearchPaths[dwDestinationSearchPath], NULL))
1421 if (FileExistsEx(pContext->rgSearchPaths[i], NULL))
1422 { 1428 {
1423 dwChosenSearchPath = i;
1424
1425 fFoundLocal = TRUE; 1429 fFoundLocal = TRUE;
1426 break; 1430 dwChosenSearchPath = dwDestinationSearchPath;
1431 }
1432 else
1433 {
1434 fPreferExtract = TRUE;
1435 }
1436 }
1437
1438 if (!fFoundLocal)
1439 {
1440 for (DWORD i = 0; i < pContext->cSearchPaths; ++i)
1441 {
1442 // If the file exists locally, choose it.
1443 if (FileExistsEx(pContext->rgSearchPaths[i], NULL))
1444 {
1445 dwChosenSearchPath = i;
1446
1447 fFoundLocal = TRUE;
1448 break;
1449 }
1427 } 1450 }
1428 } 1451 }
1429 1452
@@ -1436,7 +1459,11 @@ static HRESULT AcquireContainerOrPayload(
1436 } 1459 }
1437 else 1460 else
1438 { 1461 {
1439 if (fFoundLocal) // the file exists locally, so copy it. 1462 if (fPreferExtract) // the file comes from a container which hasn't been extracted yet, so extract it.
1463 {
1464 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_CONTAINER;
1465 }
1466 else if (fFoundLocal) // the file exists locally, so copy it.
1440 { 1467 {
1441 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_LOCAL; 1468 resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_LOCAL;
1442 } 1469 }
diff --git a/src/engine/cache.cpp b/src/engine/cache.cpp
index 764de065..2a40010d 100644
--- a/src/engine/cache.cpp
+++ b/src/engine/cache.cpp
@@ -441,7 +441,8 @@ extern "C" HRESULT CacheGetLocalSourcePaths(
441 __in BURN_VARIABLES* pVariables, 441 __in BURN_VARIABLES* pVariables,
442 __inout LPWSTR** prgSearchPaths, 442 __inout LPWSTR** prgSearchPaths,
443 __out DWORD* pcSearchPaths, 443 __out DWORD* pcSearchPaths,
444 __out DWORD* pdwLikelySearchPath 444 __out DWORD* pdwLikelySearchPath,
445 __out DWORD* pdwDestinationSearchPath
445 ) 446 )
446{ 447{
447 HRESULT hr = S_OK; 448 HRESULT hr = S_OK;
@@ -454,6 +455,7 @@ extern "C" HRESULT CacheGetLocalSourcePaths(
454 BOOL fSourceIsAbsolute = FALSE; 455 BOOL fSourceIsAbsolute = FALSE;
455 DWORD cSearchPaths = 0; 456 DWORD cSearchPaths = 0;
456 DWORD dwLikelySearchPath = 0; 457 DWORD dwLikelySearchPath = 0;
458 DWORD dwDestinationSearchPath = 0;
457 459
458 AssertSz(vfInitializedCache, "Cache wasn't initialized"); 460 AssertSz(vfInitializedCache, "Cache wasn't initialized");
459 461
@@ -486,6 +488,7 @@ extern "C" HRESULT CacheGetLocalSourcePaths(
486 hr = MemEnsureArraySize(reinterpret_cast<LPVOID*>(prgSearchPaths), cSearchPaths + 1, sizeof(LPWSTR), BURN_CACHE_MAX_SEARCH_PATHS); 488 hr = MemEnsureArraySize(reinterpret_cast<LPVOID*>(prgSearchPaths), cSearchPaths + 1, sizeof(LPWSTR), BURN_CACHE_MAX_SEARCH_PATHS);
487 ExitOnFailure(hr, "Failed to ensure size for search paths array."); 489 ExitOnFailure(hr, "Failed to ensure size for search paths array.");
488 490
491 dwDestinationSearchPath = cSearchPaths;
489 psczPath = *prgSearchPaths + cSearchPaths; 492 psczPath = *prgSearchPaths + cSearchPaths;
490 ++cSearchPaths; 493 ++cSearchPaths;
491 494
@@ -602,6 +605,7 @@ LExit:
602 AssertSz(cSearchPaths <= BURN_CACHE_MAX_SEARCH_PATHS, "Got more than BURN_CACHE_MAX_SEARCH_PATHS search paths"); 605 AssertSz(cSearchPaths <= BURN_CACHE_MAX_SEARCH_PATHS, "Got more than BURN_CACHE_MAX_SEARCH_PATHS search paths");
603 *pcSearchPaths = cSearchPaths; 606 *pcSearchPaths = cSearchPaths;
604 *pdwLikelySearchPath = dwLikelySearchPath; 607 *pdwLikelySearchPath = dwLikelySearchPath;
608 *pdwDestinationSearchPath = dwDestinationSearchPath;
605 609
606 return hr; 610 return hr;
607} 611}
diff --git a/src/engine/cache.h b/src/engine/cache.h
index afa18e47..a2ac1696 100644
--- a/src/engine/cache.h
+++ b/src/engine/cache.h
@@ -102,7 +102,8 @@ HRESULT CacheGetLocalSourcePaths(
102 __in BURN_VARIABLES* pVariables, 102 __in BURN_VARIABLES* pVariables,
103 __inout LPWSTR** prgSearchPaths, 103 __inout LPWSTR** prgSearchPaths,
104 __out DWORD* pcSearchPaths, 104 __out DWORD* pcSearchPaths,
105 __out DWORD* pdwLikelySearchPath 105 __out DWORD* pdwLikelySearchPath,
106 __out DWORD* pdwDestinationSearchPath
106 ); 107 );
107HRESULT CacheSetLastUsedSource( 108HRESULT CacheSetLastUsedSource(
108 __in BURN_VARIABLES* pVariables, 109 __in BURN_VARIABLES* pVariables,