diff options
Diffstat (limited to 'src/engine/apply.cpp')
| -rw-r--r-- | src/engine/apply.cpp | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp index 1bc01d44..9cba0483 100644 --- a/src/engine/apply.cpp +++ b/src/engine/apply.cpp | |||
| @@ -1390,6 +1390,7 @@ static HRESULT AcquireContainerOrPayload( | |||
| 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 | BOOTSTRAPPER_CACHE_OPERATION cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE; | 1392 | BOOTSTRAPPER_CACHE_OPERATION cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE; |
| 1393 | BOOTSTRAPPER_CACHE_RESOLVE_OPERATION resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_NONE; | ||
| 1393 | LPWSTR* pwzDownloadUrl = pContainer ? &pContainer->downloadSource.sczUrl : &pPayload->downloadSource.sczUrl; | 1394 | LPWSTR* pwzDownloadUrl = pContainer ? &pContainer->downloadSource.sczUrl : &pPayload->downloadSource.sczUrl; |
| 1394 | LPWSTR* pwzSourcePath = pContainer ? &pContainer->sczSourcePath : &pPayload->sczSourcePath; | 1395 | LPWSTR* pwzSourcePath = pContainer ? &pContainer->sczSourcePath : &pPayload->sczSourcePath; |
| 1395 | BOOL fFoundLocal = FALSE; | 1396 | BOOL fFoundLocal = FALSE; |
| @@ -1405,47 +1406,70 @@ static HRESULT AcquireContainerOrPayload( | |||
| 1405 | if (BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD != cacheOperation && | 1406 | if (BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD != cacheOperation && |
| 1406 | BOOTSTRAPPER_CACHE_OPERATION_EXTRACT != cacheOperation) | 1407 | BOOTSTRAPPER_CACHE_OPERATION_EXTRACT != cacheOperation) |
| 1407 | { | 1408 | { |
| 1408 | hr = CacheGetLocalSourcePaths(wzRelativePath, *pwzSourcePath, wzDestinationPath, pContext->wzLayoutDirectory, pContext->pVariables, &pContext->rgSearchPaths, &pContext->cSearchPaths); | 1409 | do |
| 1409 | ExitOnFailure(hr, "Failed to search local source."); | ||
| 1410 | |||
| 1411 | for (DWORD i = 0; i < pContext->cSearchPaths; ++i) | ||
| 1412 | { | 1410 | { |
| 1413 | // If the file exists locally, choose it. | 1411 | fFoundLocal = FALSE; |
| 1414 | if (FileExistsEx(pContext->rgSearchPaths[i], NULL)) | 1412 | resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_NONE; |
| 1415 | { | 1413 | dwChosenSearchPath = 0; |
| 1416 | dwChosenSearchPath = i; | ||
| 1417 | 1414 | ||
| 1418 | fFoundLocal = TRUE; | 1415 | hr = CacheGetLocalSourcePaths(wzRelativePath, *pwzSourcePath, wzDestinationPath, pContext->wzLayoutDirectory, pContext->pVariables, &pContext->rgSearchPaths, &pContext->cSearchPaths, &dwChosenSearchPath); |
| 1419 | break; | 1416 | ExitOnFailure(hr, "Failed to search local source."); |
| 1420 | } | ||
| 1421 | } | ||
| 1422 | 1417 | ||
| 1423 | if (BOOTSTRAPPER_CACHE_OPERATION_COPY == cacheOperation) | 1418 | for (DWORD i = 0; i < pContext->cSearchPaths; ++i) |
| 1424 | { | ||
| 1425 | if (!fFoundLocal) | ||
| 1426 | { | 1419 | { |
| 1427 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE; | 1420 | // If the file exists locally, choose it. |
| 1421 | if (FileExistsEx(pContext->rgSearchPaths[i], NULL)) | ||
| 1422 | { | ||
| 1423 | dwChosenSearchPath = i; | ||
| 1424 | |||
| 1425 | fFoundLocal = TRUE; | ||
| 1426 | break; | ||
| 1427 | } | ||
| 1428 | } | 1428 | } |
| 1429 | } | 1429 | |
| 1430 | else | 1430 | if (BOOTSTRAPPER_CACHE_OPERATION_COPY == cacheOperation) |
| 1431 | { | ||
| 1432 | if (fFoundLocal) // the file exists locally, so copy it. | ||
| 1433 | { | 1431 | { |
| 1434 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_COPY; | 1432 | if (fFoundLocal) |
| 1433 | { | ||
| 1434 | resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_LOCAL; | ||
| 1435 | } | ||
| 1435 | } | 1436 | } |
| 1436 | else if (wzPayloadContainerId) | 1437 | else |
| 1437 | { | 1438 | { |
| 1438 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_EXTRACT; | 1439 | if (fFoundLocal) // the file exists locally, so copy it. |
| 1440 | { | ||
| 1441 | resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_LOCAL; | ||
| 1442 | } | ||
| 1443 | else if (wzPayloadContainerId) | ||
| 1444 | { | ||
| 1445 | resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_CONTAINER; | ||
| 1446 | } | ||
| 1447 | else if (*pwzDownloadUrl && **pwzDownloadUrl) | ||
| 1448 | { | ||
| 1449 | resolveOperation = BOOTSTRAPPER_CACHE_RESOLVE_DOWNLOAD; | ||
| 1450 | } | ||
| 1439 | } | 1451 | } |
| 1440 | else if (*pwzDownloadUrl && **pwzDownloadUrl) | 1452 | |
| 1453 | // Let the BA have a chance to override the source. | ||
| 1454 | hr = UserExperienceOnCacheAcquireResolving(pContext->pUX, wzPackageOrContainerId, wzPayloadId, pContext->rgSearchPaths, pContext->cSearchPaths, fFoundLocal, &dwChosenSearchPath, pwzDownloadUrl, wzPayloadContainerId, &resolveOperation); | ||
| 1455 | ExitOnRootFailure(hr, "BA aborted cache acquire resolving."); | ||
| 1456 | |||
| 1457 | switch (resolveOperation) | ||
| 1441 | { | 1458 | { |
| 1459 | case BOOTSTRAPPER_CACHE_RESOLVE_LOCAL: | ||
| 1460 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_COPY; | ||
| 1461 | break; | ||
| 1462 | case BOOTSTRAPPER_CACHE_RESOLVE_DOWNLOAD: | ||
| 1442 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD; | 1463 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD; |
| 1464 | break; | ||
| 1465 | case BOOTSTRAPPER_CACHE_RESOLVE_CONTAINER: | ||
| 1466 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_EXTRACT; | ||
| 1467 | break; | ||
| 1468 | case BOOTSTRAPPER_CACHE_RESOLVE_RETRY: | ||
| 1469 | pContext->cSearchPathsMax = max(pContext->cSearchPaths, pContext->cSearchPathsMax); | ||
| 1470 | break; | ||
| 1443 | } | 1471 | } |
| 1444 | } | 1472 | } while (BOOTSTRAPPER_CACHE_RESOLVE_RETRY == resolveOperation); |
| 1445 | |||
| 1446 | // Let the BA have a chance to override the action, but their chance to change the source is during begin or complete. | ||
| 1447 | hr = UserExperienceOnCacheAcquireResolving(pContext->pUX, wzPackageOrContainerId, wzPayloadId, pContext->rgSearchPaths, pContext->cSearchPaths, fFoundLocal, &dwChosenSearchPath, *pwzDownloadUrl, wzPayloadContainerId, &cacheOperation); | ||
| 1448 | ExitOnRootFailure(hr, "BA aborted cache acquire resolving."); | ||
| 1449 | } | 1473 | } |
| 1450 | 1474 | ||
| 1451 | switch (cacheOperation) | 1475 | switch (cacheOperation) |
