aboutsummaryrefslogtreecommitdiff
path: root/src/engine/apply.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/apply.cpp')
-rw-r--r--src/engine/apply.cpp45
1 files changed, 36 insertions, 9 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 }