diff options
Diffstat (limited to 'src/engine/apply.cpp')
-rw-r--r-- | src/engine/apply.cpp | 85 |
1 files changed, 76 insertions, 9 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp index 5826f513..f40b3841 100644 --- a/src/engine/apply.cpp +++ b/src/engine/apply.cpp | |||
@@ -15,6 +15,7 @@ enum BURN_CACHE_PROGRESS_TYPE | |||
15 | { | 15 | { |
16 | BURN_CACHE_PROGRESS_TYPE_ACQUIRE, | 16 | BURN_CACHE_PROGRESS_TYPE_ACQUIRE, |
17 | BURN_CACHE_PROGRESS_TYPE_VERIFY, | 17 | BURN_CACHE_PROGRESS_TYPE_VERIFY, |
18 | BURN_CACHE_PROGRESS_TYPE_CONTAINER_OR_PAYLOAD_VERIFY, | ||
18 | }; | 19 | }; |
19 | 20 | ||
20 | // structs | 21 | // structs |
@@ -101,6 +102,12 @@ static HRESULT ApplyProcessPayload( | |||
101 | __in_opt BURN_PACKAGE* pPackage, | 102 | __in_opt BURN_PACKAGE* pPackage, |
102 | __in BURN_PAYLOAD* pPayload | 103 | __in BURN_PAYLOAD* pPayload |
103 | ); | 104 | ); |
105 | static HRESULT ApplyCacheVerifyContainerOrPayload( | ||
106 | __in BURN_CACHE_CONTEXT* pContext, | ||
107 | __in_opt BURN_CONTAINER* pContainer, | ||
108 | __in_opt BURN_PACKAGE* pPackage, | ||
109 | __in_opt BURN_PAYLOAD* pPayload | ||
110 | ); | ||
104 | static HRESULT ExtractContainer( | 111 | static HRESULT ExtractContainer( |
105 | __in BURN_CACHE_CONTEXT* pContext, | 112 | __in BURN_CACHE_CONTEXT* pContext, |
106 | __in BURN_CONTAINER* pContainer | 113 | __in BURN_CONTAINER* pContainer |
@@ -910,11 +917,9 @@ static HRESULT ApplyLayoutContainer( | |||
910 | 917 | ||
911 | Assert(!pContainer->fAttached); | 918 | Assert(!pContainer->fAttached); |
912 | 919 | ||
913 | hr = CacheVerifyContainer(pContainer, pContext->wzLayoutDirectory); | 920 | hr = ApplyCacheVerifyContainerOrPayload(pContext, pContainer, NULL, NULL); |
914 | if (SUCCEEDED(hr)) | 921 | if (SUCCEEDED(hr)) |
915 | { | 922 | { |
916 | // TODO: send Acquire and Verify messages to BA? | ||
917 | pContext->qwSuccessfulCacheProgress += pContainer->qwFileSize * 2; | ||
918 | ExitFunction(); | 923 | ExitFunction(); |
919 | } | 924 | } |
920 | 925 | ||
@@ -969,11 +974,9 @@ static HRESULT ApplyProcessPayload( | |||
969 | ExitFunction(); | 974 | ExitFunction(); |
970 | } | 975 | } |
971 | 976 | ||
972 | hr = CacheVerifyPayload(pPayload, pContext->wzLayoutDirectory ? pContext->wzLayoutDirectory : pPackage->sczCacheFolder); | 977 | hr = ApplyCacheVerifyContainerOrPayload(pContext, NULL, pPackage, pPayload); |
973 | if (SUCCEEDED(hr)) | 978 | if (SUCCEEDED(hr)) |
974 | { | 979 | { |
975 | // TODO: send Acquire and Verify messages to BA? | ||
976 | pContext->qwSuccessfulCacheProgress += pPayload->qwFileSize * 2; | ||
977 | ExitFunction(); | 980 | ExitFunction(); |
978 | } | 981 | } |
979 | 982 | ||
@@ -1012,6 +1015,54 @@ LExit: | |||
1012 | return hr; | 1015 | return hr; |
1013 | } | 1016 | } |
1014 | 1017 | ||
1018 | static HRESULT ApplyCacheVerifyContainerOrPayload( | ||
1019 | __in BURN_CACHE_CONTEXT* pContext, | ||
1020 | __in_opt BURN_CONTAINER* pContainer, | ||
1021 | __in_opt BURN_PACKAGE* pPackage, | ||
1022 | __in_opt BURN_PAYLOAD* pPayload | ||
1023 | ) | ||
1024 | { | ||
1025 | AssertSz(pContainer || pPayload, "Must provide a container or a payload."); | ||
1026 | |||
1027 | HRESULT hr = S_OK; | ||
1028 | BURN_CACHE_PROGRESS_CONTEXT progress = { }; | ||
1029 | LPCWSTR wzPackageOrContainerId = pContainer ? pContainer->sczId : pPackage ? pPackage->sczId : NULL; | ||
1030 | LPCWSTR wzPayloadId = pPayload ? pPayload->sczKey : NULL; | ||
1031 | |||
1032 | progress.pCacheContext = pContext; | ||
1033 | progress.pContainer = pContainer; | ||
1034 | progress.pPackage = pPackage; | ||
1035 | progress.pPayload = pPayload; | ||
1036 | progress.type = BURN_CACHE_PROGRESS_TYPE_CONTAINER_OR_PAYLOAD_VERIFY; | ||
1037 | |||
1038 | hr = UserExperienceOnCacheContainerOrPayloadVerifyBegin(pContext->pUX, wzPackageOrContainerId, wzPayloadId); | ||
1039 | ExitOnRootFailure(hr, "BA aborted cache container or payload verify begin."); | ||
1040 | |||
1041 | if (pContainer) | ||
1042 | { | ||
1043 | hr = CacheVerifyContainer(pContainer, pContext->wzLayoutDirectory); | ||
1044 | } | ||
1045 | else | ||
1046 | { | ||
1047 | hr = CacheVerifyPayload(pPayload, pContext->wzLayoutDirectory ? pContext->wzLayoutDirectory : pPackage->sczCacheFolder); | ||
1048 | } | ||
1049 | |||
1050 | // This was best effort to avoid acquiring the container or payload. | ||
1051 | if (FAILED(hr)) | ||
1052 | { | ||
1053 | ExitFunction(); | ||
1054 | } | ||
1055 | |||
1056 | pContext->qwSuccessfulCacheProgress += pContainer ? pContainer->qwFileSize : pPayload->qwFileSize; | ||
1057 | |||
1058 | hr = CompleteCacheProgress(&progress, pContainer ? pContainer->qwFileSize : pPayload->qwFileSize); | ||
1059 | |||
1060 | LExit: | ||
1061 | UserExperienceOnCacheContainerOrPayloadVerifyComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr); | ||
1062 | |||
1063 | return hr; | ||
1064 | } | ||
1065 | |||
1015 | static HRESULT ExtractContainer( | 1066 | static HRESULT ExtractContainer( |
1016 | __in BURN_CACHE_CONTEXT* pContext, | 1067 | __in BURN_CACHE_CONTEXT* pContext, |
1017 | __in BURN_CONTAINER* pContainer | 1068 | __in BURN_CONTAINER* pContainer |
@@ -1112,9 +1163,21 @@ static HRESULT LayoutBundle( | |||
1112 | 1163 | ||
1113 | if (CSTR_EQUAL == nEquivalentPaths && FileExistsEx(sczDestinationPath, NULL)) | 1164 | if (CSTR_EQUAL == nEquivalentPaths && FileExistsEx(sczDestinationPath, NULL)) |
1114 | { | 1165 | { |
1115 | // TODO: send Acquire and Verify messages to BA? | 1166 | hr = UserExperienceOnCacheContainerOrPayloadVerifyBegin(pContext->pUX, NULL, NULL); |
1116 | pContext->qwSuccessfulCacheProgress += 2 * qwBundleSize; | 1167 | if (FAILED(hr)) |
1117 | ExitFunction1(hr = S_OK); | 1168 | { |
1169 | UserExperienceOnCacheContainerOrPayloadVerifyComplete(pContext->pUX, NULL, NULL, hr); | ||
1170 | ExitOnRootFailure(hr, "BA aborted cache payload verify begin."); | ||
1171 | } | ||
1172 | |||
1173 | pContext->qwSuccessfulCacheProgress += qwBundleSize; | ||
1174 | |||
1175 | progress.type = BURN_CACHE_PROGRESS_TYPE_CONTAINER_OR_PAYLOAD_VERIFY; | ||
1176 | hr = CompleteCacheProgress(&progress, qwBundleSize); | ||
1177 | |||
1178 | UserExperienceOnCacheContainerOrPayloadVerifyComplete(pContext->pUX, NULL, NULL, hr); | ||
1179 | |||
1180 | ExitFunction(); | ||
1118 | } | 1181 | } |
1119 | 1182 | ||
1120 | do | 1183 | do |
@@ -1702,6 +1765,10 @@ static DWORD CALLBACK CacheProgressRoutine( | |||
1702 | hr = UserExperienceOnCacheVerifyProgress(pProgress->pCacheContext->pUX, wzPackageOrContainerId, wzPayloadId, TotalBytesTransferred.QuadPart, TotalFileSize.QuadPart, dwOverallPercentage); | 1765 | hr = UserExperienceOnCacheVerifyProgress(pProgress->pCacheContext->pUX, wzPackageOrContainerId, wzPayloadId, TotalBytesTransferred.QuadPart, TotalFileSize.QuadPart, dwOverallPercentage); |
1703 | ExitOnRootFailure(hr, "BA aborted verify of %hs: %ls", pProgress->pContainer ? "container" : "payload", pProgress->pContainer ? wzPackageOrContainerId : wzPayloadId); | 1766 | ExitOnRootFailure(hr, "BA aborted verify of %hs: %ls", pProgress->pContainer ? "container" : "payload", pProgress->pContainer ? wzPackageOrContainerId : wzPayloadId); |
1704 | break; | 1767 | break; |
1768 | case BURN_CACHE_PROGRESS_TYPE_CONTAINER_OR_PAYLOAD_VERIFY: | ||
1769 | hr = UserExperienceOnCacheContainerOrPayloadVerifyProgress(pProgress->pCacheContext->pUX, wzPackageOrContainerId, wzPayloadId, TotalBytesTransferred.QuadPart, TotalFileSize.QuadPart, dwOverallPercentage); | ||
1770 | ExitOnRootFailure(hr, "BA aborted container or payload verify: %ls", wzPayloadId); | ||
1771 | break; | ||
1705 | } | 1772 | } |
1706 | 1773 | ||
1707 | LExit: | 1774 | LExit: |