From b941c2754748251520dc5032d11396c9844fad8e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 16 Apr 2021 10:18:24 -0500 Subject: Verify file in the cache before trying to acquire it. --- src/engine/apply.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/engine/apply.cpp') diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp index 7e03ebf9..dffbc6d6 100644 --- a/src/engine/apply.cpp +++ b/src/engine/apply.cpp @@ -768,6 +768,12 @@ static HRESULT ApplyCachePackage( HRESULT hr = S_OK; BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION cachePackageCompleteAction = BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION_NONE; + if (!pPackage->sczCacheFolder && !pContext->wzLayoutDirectory) + { + hr = CacheGetCompletedPath(pPackage->fPerMachine, pPackage->sczCacheId, &pPackage->sczCacheFolder); + ExitOnFailure(hr, "Failed to get cached path for package with cache id: %ls", pPackage->sczCacheId); + } + for (;;) { hr = UserExperienceOnCachePackageBegin(pContext->pUX, pPackage->sczId, pPackage->payloads.cPayloads, pPackage->payloads.qwTotalSize); @@ -872,6 +878,14 @@ static HRESULT ApplyLayoutContainer( Assert(!pContainer->fAttached); + hr = CacheVerifyContainer(pContainer, pContext->wzLayoutDirectory); + if (SUCCEEDED(hr)) + { + // TODO: send Acquire and Verify messages to BA? + pContext->qwSuccessfulCacheProgress += pContainer->qwFileSize * 2; + ExitFunction(); + } + for (;;) { fRetry = FALSE; @@ -916,7 +930,20 @@ static HRESULT ApplyProcessPayload( DWORD cTryAgainAttempts = 0; BOOL fRetry = FALSE; - Assert(pContext->pPayloads || pContext->wzLayoutDirectory); + Assert(pContext->pPayloads && pPackage || pContext->wzLayoutDirectory); + + if (pPayload->pContainer && pContext->wzLayoutDirectory) + { + ExitFunction(); + } + + hr = CacheVerifyPayload(pPayload, pContext->wzLayoutDirectory ? pContext->wzLayoutDirectory : pPackage->sczCacheFolder); + if (SUCCEEDED(hr)) + { + // TODO: send Acquire and Verify messages to BA? + pContext->qwSuccessfulCacheProgress += pPayload->qwFileSize * 2; + ExitFunction(); + } for (;;) { @@ -924,12 +951,7 @@ static HRESULT ApplyProcessPayload( if (pPayload->pContainer) { - if (pContext->wzLayoutDirectory) - { - ExitFunction(); - } - - // TODO: only extract container if payload isn't already cached and isn't already extracted + // TODO: only extract container if payload isn't already extracted hr = ApplyExtractContainer(pContext, pPayload->pContainer); ExitOnFailure(hr, "Failed to extract container for payload: %ls", pPayload->sczKey); } -- cgit v1.2.3-55-g6feb