aboutsummaryrefslogtreecommitdiff
path: root/src/engine/apply.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-04-16 13:38:16 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-04-19 23:12:55 -0500
commitb1d1e523f5cdadce0cbf105179b33c014d5ec9eb (patch)
tree0eecd05821adb317471118c434f02974586bec03 /src/engine/apply.cpp
parentc308746132f3ab89458b446f659f3d4073758da6 (diff)
downloadwix-b1d1e523f5cdadce0cbf105179b33c014d5ec9eb.tar.gz
wix-b1d1e523f5cdadce0cbf105179b33c014d5ec9eb.tar.bz2
wix-b1d1e523f5cdadce0cbf105179b33c014d5ec9eb.zip
Add OnCachePayloadExtract*.
Diffstat (limited to 'src/engine/apply.cpp')
-rw-r--r--src/engine/apply.cpp58
1 files changed, 54 insertions, 4 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp
index f80baf26..ab7fa077 100644
--- a/src/engine/apply.cpp
+++ b/src/engine/apply.cpp
@@ -16,6 +16,7 @@ enum BURN_CACHE_PROGRESS_TYPE
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 BURN_CACHE_PROGRESS_TYPE_CONTAINER_OR_PAYLOAD_VERIFY,
19 BURN_CACHE_PROGRESS_TYPE_EXTRACT,
19}; 20};
20 21
21// structs 22// structs
@@ -43,6 +44,7 @@ typedef struct _BURN_CACHE_PROGRESS_CONTEXT
43 BURN_CONTAINER* pContainer; 44 BURN_CONTAINER* pContainer;
44 BURN_PACKAGE* pPackage; 45 BURN_PACKAGE* pPackage;
45 BURN_PAYLOAD_GROUP_ITEM* pPayloadGroupItem; 46 BURN_PAYLOAD_GROUP_ITEM* pPayloadGroupItem;
47 BURN_PAYLOAD* pPayload;
46 48
47 BOOL fCancel; 49 BOOL fCancel;
48 HRESULT hrError; 50 HRESULT hrError;
@@ -875,6 +877,12 @@ static HRESULT ApplyExtractContainer(
875 pContainer->qwCommittedCacheProgress = 0; 877 pContainer->qwCommittedCacheProgress = 0;
876 } 878 }
877 879
880 if (pContainer->qwCommittedExtractProgress)
881 {
882 pContext->qwSuccessfulCacheProgress -= pContainer->qwCommittedExtractProgress;
883 pContainer->qwCommittedExtractProgress = 0;
884 }
885
878 if (!pContainer->fActuallyAttached) 886 if (!pContainer->fActuallyAttached)
879 { 887 {
880 hr = ApplyAcquireContainerOrPayload(pContext, pContainer, NULL, NULL); 888 hr = ApplyAcquireContainerOrPayload(pContext, pContainer, NULL, NULL);
@@ -890,8 +898,18 @@ static HRESULT ApplyExtractContainer(
890 CacheSetLastUsedSource(pContext->pVariables, pContext->sczLastUsedFolderCandidate, pContainer->sczFilePath); 898 CacheSetLastUsedSource(pContext->pVariables, pContext->sczLastUsedFolderCandidate, pContainer->sczFilePath);
891 } 899 }
892 900
893 pContext->qwSuccessfulCacheProgress += pContainer->qwExtractSizeTotal; 901 if (pContainer->qwExtractSizeTotal < pContainer->qwCommittedExtractProgress)
894 pContainer->qwCommittedCacheProgress += pContainer->qwExtractSizeTotal; 902 {
903 AssertSz(FALSE, "Container extracted more than planned.");
904 pContext->qwSuccessfulCacheProgress -= pContainer->qwCommittedExtractProgress;
905 pContext->qwSuccessfulCacheProgress += pContainer->qwExtractSizeTotal;
906 }
907 else
908 {
909 pContext->qwSuccessfulCacheProgress += pContainer->qwExtractSizeTotal - pContainer->qwCommittedExtractProgress;
910 }
911
912 pContainer->qwCommittedExtractProgress = pContainer->qwExtractSizeTotal;
895 913
896LExit: 914LExit:
897 ReleaseNullStr(pContext->sczLastUsedFolderCandidate); 915 ReleaseNullStr(pContext->sczLastUsedFolderCandidate);
@@ -1100,6 +1118,11 @@ static HRESULT ExtractContainer(
1100 BURN_CONTAINER_CONTEXT context = { }; 1118 BURN_CONTAINER_CONTEXT context = { };
1101 HANDLE hContainerHandle = INVALID_HANDLE_VALUE; 1119 HANDLE hContainerHandle = INVALID_HANDLE_VALUE;
1102 LPWSTR sczExtractPayloadId = NULL; 1120 LPWSTR sczExtractPayloadId = NULL;
1121 BURN_CACHE_PROGRESS_CONTEXT progress = { };
1122
1123 progress.pCacheContext = pContext;
1124 progress.pContainer = pContainer;
1125 progress.type = BURN_CACHE_PROGRESS_TYPE_EXTRACT;
1103 1126
1104 // If the container is actually attached, then it was planned to be acquired through hSourceEngineFile. 1127 // If the container is actually attached, then it was planned to be acquired through hSourceEngineFile.
1105 if (pContainer->fActuallyAttached) 1128 if (pContainer->fActuallyAttached)
@@ -1119,11 +1142,29 @@ static HRESULT ExtractContainer(
1119 BURN_PAYLOAD* pExtract = pContext->pPayloads->rgPayloads + iExtract; 1142 BURN_PAYLOAD* pExtract = pContext->pPayloads->rgPayloads + iExtract;
1120 if (pExtract->sczUnverifiedPath && pExtract->cRemainingInstances && CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczExtractPayloadId, -1, pExtract->sczSourcePath, -1)) 1143 if (pExtract->sczUnverifiedPath && pExtract->cRemainingInstances && CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczExtractPayloadId, -1, pExtract->sczSourcePath, -1))
1121 { 1144 {
1145 progress.pPayload = pExtract;
1146
1122 hr = PreparePayloadDestinationPath(pExtract->sczUnverifiedPath); 1147 hr = PreparePayloadDestinationPath(pExtract->sczUnverifiedPath);
1123 ExitOnFailure(hr, "Failed to prepare payload destination path: %ls", pExtract->sczUnverifiedPath); 1148 ExitOnFailure(hr, "Failed to prepare payload destination path: %ls", pExtract->sczUnverifiedPath);
1124 1149
1150 hr = UserExperienceOnCachePayloadExtractBegin(pContext->pUX, pContainer->sczId, pExtract->sczKey);
1151 if (FAILED(hr))
1152 {
1153 UserExperienceOnCachePayloadExtractComplete(pContext->pUX, pContainer->sczId, pExtract->sczKey, hr);
1154 ExitOnRootFailure(hr, "BA aborted cache payload extract begin.");
1155 }
1156
1125 // TODO: Send progress when extracting stream to file. 1157 // TODO: Send progress when extracting stream to file.
1126 hr = ContainerStreamToFile(&context, pExtract->sczUnverifiedPath); 1158 hr = ContainerStreamToFile(&context, pExtract->sczUnverifiedPath);
1159 // Error handling happens after sending complete message to BA.
1160
1161 // If succeeded, send 100% complete here to make sure progress was sent to the BA.
1162 if (SUCCEEDED(hr))
1163 {
1164 hr = CompleteCacheProgress(&progress, pExtract->qwFileSize);
1165 }
1166
1167 UserExperienceOnCachePayloadExtractComplete(pContext->pUX, pContainer->sczId, pExtract->sczKey, hr);
1127 ExitOnFailure(hr, "Failed to extract payload: %ls from container: %ls", sczExtractPayloadId, pContainer->sczId); 1168 ExitOnFailure(hr, "Failed to extract payload: %ls from container: %ls", sczExtractPayloadId, pContainer->sczId);
1128 1169
1129 fExtracted = TRUE; 1170 fExtracted = TRUE;
@@ -1754,7 +1795,12 @@ static HRESULT CompleteCacheProgress(
1754 if (PROGRESS_CONTINUE == dwResult) 1795 if (PROGRESS_CONTINUE == dwResult)
1755 { 1796 {
1756 pContext->pCacheContext->qwSuccessfulCacheProgress += qwFileSize; 1797 pContext->pCacheContext->qwSuccessfulCacheProgress += qwFileSize;
1757 if (pContext->pContainer) 1798
1799 if (pContext->pPayload)
1800 {
1801 pContext->pContainer->qwCommittedExtractProgress += qwFileSize;
1802 }
1803 else if (pContext->pContainer)
1758 { 1804 {
1759 pContext->pContainer->qwCommittedCacheProgress += qwFileSize; 1805 pContext->pContainer->qwCommittedCacheProgress += qwFileSize;
1760 } 1806 }
@@ -1800,7 +1846,7 @@ static DWORD CALLBACK CacheProgressRoutine(
1800 DWORD dwResult = PROGRESS_CONTINUE; 1846 DWORD dwResult = PROGRESS_CONTINUE;
1801 BURN_CACHE_PROGRESS_CONTEXT* pProgress = static_cast<BURN_CACHE_PROGRESS_CONTEXT*>(lpData); 1847 BURN_CACHE_PROGRESS_CONTEXT* pProgress = static_cast<BURN_CACHE_PROGRESS_CONTEXT*>(lpData);
1802 LPCWSTR wzPackageOrContainerId = pProgress->pContainer ? pProgress->pContainer->sczId : pProgress->pPackage ? pProgress->pPackage->sczId : NULL; 1848 LPCWSTR wzPackageOrContainerId = pProgress->pContainer ? pProgress->pContainer->sczId : pProgress->pPackage ? pProgress->pPackage->sczId : NULL;
1803 LPCWSTR wzPayloadId = pProgress->pPayloadGroupItem ? pProgress->pPayloadGroupItem->pPayload->sczKey : NULL; 1849 LPCWSTR wzPayloadId = pProgress->pPayloadGroupItem ? pProgress->pPayloadGroupItem->pPayload->sczKey : pProgress->pPayload ? pProgress->pPayload->sczKey : NULL;
1804 DWORD64 qwCacheProgress = pProgress->pCacheContext->qwSuccessfulCacheProgress + TotalBytesTransferred.QuadPart; 1850 DWORD64 qwCacheProgress = pProgress->pCacheContext->qwSuccessfulCacheProgress + TotalBytesTransferred.QuadPart;
1805 if (qwCacheProgress > pProgress->pCacheContext->qwTotalCacheSize) 1851 if (qwCacheProgress > pProgress->pCacheContext->qwTotalCacheSize)
1806 { 1852 {
@@ -1823,6 +1869,10 @@ static DWORD CALLBACK CacheProgressRoutine(
1823 hr = UserExperienceOnCacheContainerOrPayloadVerifyProgress(pProgress->pCacheContext->pUX, wzPackageOrContainerId, wzPayloadId, TotalBytesTransferred.QuadPart, TotalFileSize.QuadPart, dwOverallPercentage); 1869 hr = UserExperienceOnCacheContainerOrPayloadVerifyProgress(pProgress->pCacheContext->pUX, wzPackageOrContainerId, wzPayloadId, TotalBytesTransferred.QuadPart, TotalFileSize.QuadPart, dwOverallPercentage);
1824 ExitOnRootFailure(hr, "BA aborted container or payload verify: %ls", wzPayloadId); 1870 ExitOnRootFailure(hr, "BA aborted container or payload verify: %ls", wzPayloadId);
1825 break; 1871 break;
1872 case BURN_CACHE_PROGRESS_TYPE_EXTRACT:
1873 hr = UserExperienceOnCachePayloadExtractProgress(pProgress->pCacheContext->pUX, wzPackageOrContainerId, wzPayloadId, TotalBytesTransferred.QuadPart, TotalFileSize.QuadPart, dwOverallPercentage);
1874 ExitOnRootFailure(hr, "BA aborted extract container: %ls, payload: %ls", wzPackageOrContainerId, wzPayloadId);
1875 break;
1826 } 1876 }
1827 1877
1828LExit: 1878LExit: