aboutsummaryrefslogtreecommitdiff
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
parentc308746132f3ab89458b446f659f3d4073758da6 (diff)
downloadwix-b1d1e523f5cdadce0cbf105179b33c014d5ec9eb.tar.gz
wix-b1d1e523f5cdadce0cbf105179b33c014d5ec9eb.tar.bz2
wix-b1d1e523f5cdadce0cbf105179b33c014d5ec9eb.zip
Add OnCachePayloadExtract*.
-rw-r--r--src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h45
-rw-r--r--src/engine/apply.cpp58
-rw-r--r--src/engine/container.h1
-rw-r--r--src/engine/plan.cpp1
-rw-r--r--src/engine/userexperience.cpp87
-rw-r--r--src/engine/userexperience.h19
6 files changed, 207 insertions, 4 deletions
diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
index edb981a9..e1920107 100644
--- a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
+++ b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
@@ -153,6 +153,9 @@ enum BOOTSTRAPPER_APPLICATION_MESSAGE
153 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN, 153 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYBEGIN,
154 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE, 154 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYCOMPLETE,
155 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS, 155 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHECONTAINERORPAYLOADVERIFYPROGRESS,
156 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN,
157 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE,
158 BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS,
156}; 159};
157 160
158enum BOOTSTRAPPER_APPLYCOMPLETE_ACTION 161enum BOOTSTRAPPER_APPLYCOMPLETE_ACTION
@@ -472,6 +475,48 @@ struct BA_ONCACHEPACKAGECOMPLETE_RESULTS
472 BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action; 475 BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION action;
473}; 476};
474 477
478struct BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS
479{
480 DWORD cbSize;
481 LPCWSTR wzContainerId;
482 LPCWSTR wzPayloadId;
483};
484
485struct BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS
486{
487 DWORD cbSize;
488 BOOL fCancel;
489};
490
491struct BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS
492{
493 DWORD cbSize;
494 LPCWSTR wzContainerId;
495 LPCWSTR wzPayloadId;
496 HRESULT hrStatus;
497};
498
499struct BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS
500{
501 DWORD cbSize;
502};
503
504struct BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS
505{
506 DWORD cbSize;
507 LPCWSTR wzContainerId;
508 LPCWSTR wzPayloadId;
509 DWORD64 dw64Progress;
510 DWORD64 dw64Total;
511 DWORD dwOverallPercentage;
512};
513
514struct BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS
515{
516 DWORD cbSize;
517 BOOL fCancel;
518};
519
475struct BA_ONCACHEVERIFYBEGIN_ARGS 520struct BA_ONCACHEVERIFYBEGIN_ARGS
476{ 521{
477 DWORD cbSize; 522 DWORD cbSize;
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:
diff --git a/src/engine/container.h b/src/engine/container.h
index 7c5c2b5f..3174eb38 100644
--- a/src/engine/container.h
+++ b/src/engine/container.h
@@ -78,6 +78,7 @@ typedef struct _BURN_CONTAINER
78 LPWSTR sczUnverifiedPath; 78 LPWSTR sczUnverifiedPath;
79 DWORD64 qwExtractSizeTotal; 79 DWORD64 qwExtractSizeTotal;
80 DWORD64 qwCommittedCacheProgress; 80 DWORD64 qwCommittedCacheProgress;
81 DWORD64 qwCommittedExtractProgress;
81} BURN_CONTAINER; 82} BURN_CONTAINER;
82 83
83typedef struct _BURN_CONTAINERS 84typedef struct _BURN_CONTAINERS
diff --git a/src/engine/plan.cpp b/src/engine/plan.cpp
index 8421d87b..bf929835 100644
--- a/src/engine/plan.cpp
+++ b/src/engine/plan.cpp
@@ -1831,6 +1831,7 @@ static void ResetPlannedContainerState(
1831 pContainer->fPlanned = FALSE; 1831 pContainer->fPlanned = FALSE;
1832 pContainer->qwExtractSizeTotal = 0; 1832 pContainer->qwExtractSizeTotal = 0;
1833 pContainer->qwCommittedCacheProgress = 0; 1833 pContainer->qwCommittedCacheProgress = 0;
1834 pContainer->qwCommittedExtractProgress = 0;
1834} 1835}
1835 1836
1836static void ResetPlannedPayloadsState( 1837static void ResetPlannedPayloadsState(
diff --git a/src/engine/userexperience.cpp b/src/engine/userexperience.cpp
index 02c67fc5..279a00b5 100644
--- a/src/engine/userexperience.cpp
+++ b/src/engine/userexperience.cpp
@@ -758,6 +758,93 @@ LExit:
758 return hr; 758 return hr;
759} 759}
760 760
761EXTERN_C BAAPI UserExperienceOnCachePayloadExtractBegin(
762 __in BURN_USER_EXPERIENCE* pUserExperience,
763 __in_z_opt LPCWSTR wzContainerId,
764 __in_z_opt LPCWSTR wzPayloadId
765 )
766{
767 HRESULT hr = S_OK;
768 BA_ONCACHEPAYLOADEXTRACTBEGIN_ARGS args = { };
769 BA_ONCACHEPAYLOADEXTRACTBEGIN_RESULTS results = { };
770
771 args.cbSize = sizeof(args);
772 args.wzContainerId = wzContainerId;
773 args.wzPayloadId = wzPayloadId;
774
775 results.cbSize = sizeof(results);
776
777 hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTBEGIN, &args, &results);
778 ExitOnFailure(hr, "BA OnCachePayloadExtractBegin failed.");
779
780 if (results.fCancel)
781 {
782 hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT);
783 }
784
785LExit:
786 return hr;
787}
788
789EXTERN_C BAAPI UserExperienceOnCachePayloadExtractComplete(
790 __in BURN_USER_EXPERIENCE* pUserExperience,
791 __in_z_opt LPCWSTR wzContainerId,
792 __in_z_opt LPCWSTR wzPayloadId,
793 __in HRESULT hrStatus
794 )
795{
796 HRESULT hr = S_OK;
797 BA_ONCACHEPAYLOADEXTRACTCOMPLETE_ARGS args = { };
798 BA_ONCACHEPAYLOADEXTRACTCOMPLETE_RESULTS results = { };
799
800 args.cbSize = sizeof(args);
801 args.wzContainerId = wzContainerId;
802 args.wzPayloadId = wzPayloadId;
803 args.hrStatus = hrStatus;
804
805 results.cbSize = sizeof(results);
806
807 hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE, &args, &results);
808 ExitOnFailure(hr, "BA OnCachePayloadExtractComplete failed.");
809
810LExit:
811 return hr;
812}
813
814EXTERN_C BAAPI UserExperienceOnCachePayloadExtractProgress(
815 __in BURN_USER_EXPERIENCE* pUserExperience,
816 __in_z_opt LPCWSTR wzContainerId,
817 __in_z_opt LPCWSTR wzPayloadId,
818 __in DWORD64 dw64Progress,
819 __in DWORD64 dw64Total,
820 __in DWORD dwOverallPercentage
821 )
822{
823 HRESULT hr = S_OK;
824 BA_ONCACHEPAYLOADEXTRACTPROGRESS_ARGS args = { };
825 BA_ONCACHEPAYLOADEXTRACTPROGRESS_RESULTS results = { };
826
827 args.cbSize = sizeof(args);
828 args.wzContainerId = wzContainerId;
829 args.wzPayloadId = wzPayloadId;
830 args.dw64Progress = dw64Progress;
831 args.dw64Total = dw64Total;
832 args.dwOverallPercentage = dwOverallPercentage;
833
834 results.cbSize = sizeof(results);
835
836 hr = SendBAMessage(pUserExperience, BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS, &args, &results);
837 ExitOnFailure(hr, "BA OnCachePayloadExtractProgress failed.");
838
839 if (results.fCancel)
840 {
841 hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT);
842 }
843
844LExit:
845 return hr;
846}
847
761EXTERN_C BAAPI UserExperienceOnCacheVerifyBegin( 848EXTERN_C BAAPI UserExperienceOnCacheVerifyBegin(
762 __in BURN_USER_EXPERIENCE* pUserExperience, 849 __in BURN_USER_EXPERIENCE* pUserExperience,
763 __in_z_opt LPCWSTR wzPackageOrContainerId, 850 __in_z_opt LPCWSTR wzPackageOrContainerId,
diff --git a/src/engine/userexperience.h b/src/engine/userexperience.h
index d3dfb810..a848e60d 100644
--- a/src/engine/userexperience.h
+++ b/src/engine/userexperience.h
@@ -196,6 +196,25 @@ BAAPI UserExperienceOnCachePackageComplete(
196 __in HRESULT hrStatus, 196 __in HRESULT hrStatus,
197 __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction 197 __inout BOOTSTRAPPER_CACHEPACKAGECOMPLETE_ACTION* pAction
198 ); 198 );
199BAAPI UserExperienceOnCachePayloadExtractBegin(
200 __in BURN_USER_EXPERIENCE* pUserExperience,
201 __in_z_opt LPCWSTR wzContainerId,
202 __in_z_opt LPCWSTR wzPayloadId
203 );
204BAAPI UserExperienceOnCachePayloadExtractComplete(
205 __in BURN_USER_EXPERIENCE* pUserExperience,
206 __in_z_opt LPCWSTR wzContainerId,
207 __in_z_opt LPCWSTR wzPayloadId,
208 __in HRESULT hrStatus
209 );
210BAAPI UserExperienceOnCachePayloadExtractProgress(
211 __in BURN_USER_EXPERIENCE* pUserExperience,
212 __in_z_opt LPCWSTR wzContainerId,
213 __in_z_opt LPCWSTR wzPayloadId,
214 __in DWORD64 dw64Progress,
215 __in DWORD64 dw64Total,
216 __in DWORD dwOverallPercentage
217 );
199BAAPI UserExperienceOnCacheVerifyBegin( 218BAAPI UserExperienceOnCacheVerifyBegin(
200 __in BURN_USER_EXPERIENCE* pUserExperience, 219 __in BURN_USER_EXPERIENCE* pUserExperience,
201 __in_z_opt LPCWSTR wzPackageOrContainerId, 220 __in_z_opt LPCWSTR wzPackageOrContainerId,