@joebigelow / wix-1 / commits / 66360b60

Only set the last used folder if the target passed verification.

Sean Hall committed Apr 16, 2021 at 10:21 UTC 66360b60b0298c88d32ce2b5e5ce5befa1c09ff8
1 file changed +31 -6
src/engine/apply.cpp
+31 -6
@@ -26,6 +26,7 @@ typedef struct _BURN_CACHE_CONTEXT
26 LPWSTR* rgSearchPaths;
27 DWORD cSearchPaths;
28 DWORD cSearchPathsMax;
29 + LPWSTR sczLastUsedFolderCandidate;
30 } BURN_CACHE_CONTEXT;
31
32 typedef struct _BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT
@@ -563,6 +564,7 @@ LExit:
564 ReleaseNullStr(cacheContext.rgSearchPaths[i]);
565 }
566 ReleaseMem(cacheContext.rgSearchPaths);
567 + ReleaseStr(cacheContext.sczLastUsedFolderCandidate);
568
569 UserExperienceOnCacheComplete(pUX, hr);
570 return hr;
@@ -840,9 +842,17 @@ static HRESULT ApplyExtractContainer(
842 hr = ExtractContainer(pContext, pContainer);
843 LogExitOnFailure(hr, MSG_FAILED_EXTRACT_CONTAINER, "Failed to extract payloads from container: %ls to working path: %ls", pContainer->sczId, pContainer->sczUnverifiedPath);
844
845 + if (pContext->sczLastUsedFolderCandidate)
846 + {
847 + // We successfully copied from a source location, set that as the last used source.
848 + CacheSetLastUsedSource(pContext->pVariables, pContext->sczLastUsedFolderCandidate, pContainer->sczFilePath);
849 + }
850 +
851 pContext->qwSuccessfulCacheProgress += pContainer->qwFileSize;
852
853 LExit:
854 + ReleaseNullStr(pContext->sczLastUsedFolderCandidate);
855 +
856 return hr;
857 }
858
@@ -901,6 +911,12 @@ static HRESULT ApplyLayoutContainer(
911 hr = LayoutOrCacheContainerOrPayload(pContext, pContainer, NULL, NULL, TRUE, cTryAgainAttempts, &fRetry);
912 if (SUCCEEDED(hr))
913 {
914 + if (pContext->sczLastUsedFolderCandidate)
915 + {
916 + // We successfully copied from a source location, set that as the last used source.
917 + CacheSetLastUsedSource(pContext->pVariables, pContext->sczLastUsedFolderCandidate, pContainer->sczFilePath);
918 + }
919 +
920 pContext->qwSuccessfulCacheProgress += pContainer->qwFileSize;
921 break;
922 }
@@ -915,11 +931,14 @@ static HRESULT ApplyLayoutContainer(
931
932 ++cTryAgainAttempts;
933 pContext->qwSuccessfulCacheProgress -= pContainer->qwFileSize;
934 + ReleaseNullStr(pContext->sczLastUsedFolderCandidate);
935 LogErrorId(hr, MSG_APPLY_RETRYING_PAYLOAD, pContainer->sczId, NULL, NULL);
936 }
937 }
938
939 LExit:
940 + ReleaseNullStr(pContext->sczLastUsedFolderCandidate);
941 +
942 return hr;
943 }
944
@@ -961,6 +980,12 @@ static HRESULT ApplyProcessPayload(
980 hr = LayoutOrCacheContainerOrPayload(pContext, NULL, pPackage, pPayload, FALSE, cTryAgainAttempts, &fRetry);
981 if (SUCCEEDED(hr))
982 {
983 + if (pContext->sczLastUsedFolderCandidate)
984 + {
985 + // We successfully copied from a source location, set that as the last used source.
986 + CacheSetLastUsedSource(pContext->pVariables, pContext->sczLastUsedFolderCandidate, pPayload->sczFilePath);
987 + }
988 +
989 pContext->qwSuccessfulCacheProgress += pPayload->qwFileSize;
990 break;
991 }
@@ -975,11 +1000,14 @@ static HRESULT ApplyProcessPayload(
1000
1001 ++cTryAgainAttempts;
1002 pContext->qwSuccessfulCacheProgress -= pPayload->qwFileSize;
1003 + ReleaseNullStr(pContext->sczLastUsedFolderCandidate);
1004 LogErrorId(hr, MSG_APPLY_RETRYING_PAYLOAD, pPayload->sczKey, NULL, NULL);
1005 }
1006 }
1007
1008 LExit:
1009 + ReleaseNullStr(pContext->sczLastUsedFolderCandidate);
1010 +
1011 return hr;
1012 }
1013
@@ -1245,12 +1273,9 @@ static HRESULT AcquireContainerOrPayload(
1273 hr = CopyPayload(&progress, INVALID_HANDLE_VALUE, pContext->rgSearchPaths[dwChosenSearchPath], wzDestinationPath);
1274 // Error handling happens after sending complete message to BA.
1275
1248 - // TODO: wait for verification?
1249 - // We successfully copied from a source location, set that as the last used source.
1250 - if (SUCCEEDED(hr))
1251 - {
1252 - CacheSetLastUsedSource(pContext->pVariables, pContext->rgSearchPaths[dwChosenSearchPath], wzRelativePath);
1253 - }
1276 + // Store the source path so it can be used as the LastUsedFolder if it passes verification.
1277 + pContext->sczLastUsedFolderCandidate = pContext->rgSearchPaths[dwChosenSearchPath];
1278 + pContext->rgSearchPaths[dwChosenSearchPath] = NULL;
1279 }
1280
1281 fBeginCalled = FALSE;