@joebigelow / wix-1 / commits / c3087461

When extracting a container use the uncompressed file size for progress Remove the container's cache progress when reextracting Skip extracting payloads that are already cached

When extracting a container use the uncompressed file size for progress Remove the container's cache progress when reextracting Skip extracting payloads that are already cached

Sean Hall committed Apr 16, 2021 at 10:56 UTC c308746132f3ab89458b446f659f3d4073758da6
4 files changed +33 -10
src/engine/apply.cpp
+14 -3
@@ -869,6 +869,12 @@ static HRESULT ApplyExtractContainer(
869 {
870 HRESULT hr = S_OK;
871
872 + if (pContainer->qwCommittedCacheProgress)
873 + {
874 + pContext->qwSuccessfulCacheProgress -= pContainer->qwCommittedCacheProgress;
875 + pContainer->qwCommittedCacheProgress = 0;
876 + }
877 +
878 if (!pContainer->fActuallyAttached)
879 {
880 hr = ApplyAcquireContainerOrPayload(pContext, pContainer, NULL, NULL);
@@ -884,7 +890,8 @@ static HRESULT ApplyExtractContainer(
890 CacheSetLastUsedSource(pContext->pVariables, pContext->sczLastUsedFolderCandidate, pContainer->sczFilePath);
891 }
892
887 - pContext->qwSuccessfulCacheProgress += pContainer->qwFileSize;
893 + pContext->qwSuccessfulCacheProgress += pContainer->qwExtractSizeTotal;
894 + pContainer->qwCommittedCacheProgress += pContainer->qwExtractSizeTotal;
895
896 LExit:
897 ReleaseNullStr(pContext->sczLastUsedFolderCandidate);
@@ -1110,7 +1117,7 @@ static HRESULT ExtractContainer(
1117 for (DWORD iExtract = 0; iExtract < pContext->pPayloads->cPayloads; ++iExtract)
1118 {
1119 BURN_PAYLOAD* pExtract = pContext->pPayloads->rgPayloads + iExtract;
1113 - if (pExtract->sczUnverifiedPath && CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczExtractPayloadId, -1, pExtract->sczSourcePath, -1))
1120 + if (pExtract->sczUnverifiedPath && pExtract->cRemainingInstances && CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, sczExtractPayloadId, -1, pExtract->sczSourcePath, -1))
1121 {
1122 hr = PreparePayloadDestinationPath(pExtract->sczUnverifiedPath);
1123 ExitOnFailure(hr, "Failed to prepare payload destination path: %ls", pExtract->sczUnverifiedPath);
@@ -1747,7 +1754,11 @@ static HRESULT CompleteCacheProgress(
1754 if (PROGRESS_CONTINUE == dwResult)
1755 {
1756 pContext->pCacheContext->qwSuccessfulCacheProgress += qwFileSize;
1750 - if (pContext->pPayloadGroupItem)
1757 + if (pContext->pContainer)
1758 + {
1759 + pContext->pContainer->qwCommittedCacheProgress += qwFileSize;
1760 + }
1761 + else if (pContext->pPayloadGroupItem)
1762 {
1763 pContext->pPayloadGroupItem->qwCommittedCacheProgress += qwFileSize;
1764 }
src/engine/container.h
+2
@@ -76,6 +76,8 @@ typedef struct _BURN_CONTAINER
76 BOOL fPlanned;
77 LPWSTR sczSourcePath;
78 LPWSTR sczUnverifiedPath;
79 + DWORD64 qwExtractSizeTotal;
80 + DWORD64 qwCommittedCacheProgress;
81 } BURN_CONTAINER;
82
83 typedef struct _BURN_CONTAINERS
src/engine/plan.cpp
+13 -3
@@ -431,6 +431,7 @@ extern "C" HRESULT PlanLayoutBundle(
431 pCacheAction->bundleLayout.qwBundleSize = qwBundleSize;
432 pCacheAction->bundleLayout.pPayloadGroup = pLayoutPayloads;
433
434 + // Acquire + Verify
435 pPlan->qwCacheSizeTotal += 2 * qwBundleSize;
436
437 ++pPlan->cOverallProgressTicksTotal;
@@ -1005,6 +1006,7 @@ extern "C" HRESULT PlanLayoutContainer(
1006 pCacheAction->type = BURN_CACHE_ACTION_TYPE_CONTAINER;
1007 pCacheAction->container.pContainer = pContainer;
1008
1009 + // Acquire + Verify
1010 pPlan->qwCacheSizeTotal += 2 * pContainer->qwFileSize;
1011 }
1012 }
@@ -1012,11 +1014,9 @@ extern "C" HRESULT PlanLayoutContainer(
1014 {
1015 if (!pContainer->fActuallyAttached)
1016 {
1017 + // Acquire
1018 pPlan->qwCacheSizeTotal += pContainer->qwFileSize;
1019 }
1017 -
1018 - // TODO: This should be the sum of all uncompressed payloads in the container, ideally restricted to the payloads that were actually planned.
1019 - pPlan->qwCacheSizeTotal += pContainer->qwFileSize;
1020 }
1021
1022 if (!pContainer->sczUnverifiedPath)
@@ -1829,6 +1829,8 @@ static void ResetPlannedContainerState(
1829 )
1830 {
1831 pContainer->fPlanned = FALSE;
1832 + pContainer->qwExtractSizeTotal = 0;
1833 + pContainer->qwCommittedCacheProgress = 0;
1834 }
1835
1836 static void ResetPlannedPayloadsState(
@@ -2246,9 +2248,17 @@ static HRESULT ProcessPayloadGroup(
2248
2249 if (!pPlan->sczLayoutDirectory || !pPayload->pContainer)
2250 {
2251 + // Acquire + Verify
2252 pPlan->qwCacheSizeTotal += 2 * pPayload->qwFileSize;
2253 }
2254
2255 + if (!pPlan->sczLayoutDirectory && pPayload->pContainer && 1 == pPayload->cRemainingInstances)
2256 + {
2257 + // Extract
2258 + pPlan->qwCacheSizeTotal += pPayload->qwFileSize;
2259 + pPayload->pContainer->qwExtractSizeTotal += pPayload->qwFileSize;
2260 + }
2261 +
2262 if (!pPayload->sczUnverifiedPath)
2263 {
2264 hr = CacheCalculatePayloadWorkingPath(pPlan->wzBundleId, pPayload, &pPayload->sczUnverifiedPath);
src/test/BurnUnitTest/PlanTest.cpp
+4 -4
@@ -71,7 +71,7 @@ namespace Bootstrapper
71 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
72
73 Assert::Equal(107082ull, pPlan->qwEstimatedSize);
74 - Assert::Equal(202458ull, pPlan->qwCacheSizeTotal);
74 + Assert::Equal(303687ull, pPlan->qwCacheSizeTotal);
75
76 fRollback = FALSE;
77 dwIndex = 0;
@@ -308,7 +308,7 @@ namespace Bootstrapper
308 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
309
310 Assert::Equal(35694ull, pPlan->qwEstimatedSize);
311 - Assert::Equal(67486ull, pPlan->qwCacheSizeTotal);
311 + Assert::Equal(101229ull, pPlan->qwCacheSizeTotal);
312
313 fRollback = FALSE;
314 dwIndex = 0;
@@ -388,7 +388,7 @@ namespace Bootstrapper
388 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
389
390 Assert::Equal(33743ull, pPlan->qwEstimatedSize);
391 - Assert::Equal(67486ull, pPlan->qwCacheSizeTotal);
391 + Assert::Equal(101229ull, pPlan->qwCacheSizeTotal);
392
393 fRollback = FALSE;
394 dwIndex = 0;
@@ -458,7 +458,7 @@ namespace Bootstrapper
458 Assert::Equal(dwIndex, pPlan->cRollbackCacheActions);
459
460 Assert::Equal(35694ull, pPlan->qwEstimatedSize);
461 - Assert::Equal(67486ull, pPlan->qwCacheSizeTotal);
461 + Assert::Equal(101229ull, pPlan->qwCacheSizeTotal);
462
463 fRollback = FALSE;
464 dwIndex = 0;