diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-16 10:20:41 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-19 23:12:55 -0500 |
commit | 5d6046bee5021052da4a666c1e2ceeb0f16af349 (patch) | |
tree | 589ddcbe270e2e4df8cffdbd26792bcee4c29e1c /src/engine/apply.cpp | |
parent | b941c2754748251520dc5032d11396c9844fad8e (diff) | |
download | wix-5d6046bee5021052da4a666c1e2ceeb0f16af349.tar.gz wix-5d6046bee5021052da4a666c1e2ceeb0f16af349.tar.bz2 wix-5d6046bee5021052da4a666c1e2ceeb0f16af349.zip |
Replace OnResolveSource with OnCacheAcquireResolving
Inactivate the engine during OnCacheAcquireBegin and Complete to allow setting the source from there.
Fixes #3640
Contributes to #5253
Diffstat (limited to 'src/engine/apply.cpp')
-rw-r--r-- | src/engine/apply.cpp | 242 |
1 files changed, 132 insertions, 110 deletions
diff --git a/src/engine/apply.cpp b/src/engine/apply.cpp index dffbc6d6..dc9f905b 100644 --- a/src/engine/apply.cpp +++ b/src/engine/apply.cpp | |||
@@ -23,6 +23,9 @@ typedef struct _BURN_CACHE_CONTEXT | |||
23 | DWORD64 qwTotalCacheSize; | 23 | DWORD64 qwTotalCacheSize; |
24 | DWORD64 qwSuccessfulCacheProgress; | 24 | DWORD64 qwSuccessfulCacheProgress; |
25 | LPCWSTR wzLayoutDirectory; | 25 | LPCWSTR wzLayoutDirectory; |
26 | LPWSTR* rgSearchPaths; | ||
27 | DWORD cSearchPaths; | ||
28 | DWORD cSearchPathsMax; | ||
26 | } BURN_CACHE_CONTEXT; | 29 | } BURN_CACHE_CONTEXT; |
27 | 30 | ||
28 | typedef struct _BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT | 31 | typedef struct _BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT |
@@ -113,15 +116,6 @@ static HRESULT LayoutOrCacheContainerOrPayload( | |||
113 | __in DWORD cTryAgainAttempts, | 116 | __in DWORD cTryAgainAttempts, |
114 | __out BOOL* pfRetry | 117 | __out BOOL* pfRetry |
115 | ); | 118 | ); |
116 | static HRESULT PromptForSource( | ||
117 | __in BURN_USER_EXPERIENCE* pUX, | ||
118 | __in_z LPCWSTR wzPackageOrContainerId, | ||
119 | __in_z_opt LPCWSTR wzPayloadId, | ||
120 | __in_z LPCWSTR wzLocalSource, | ||
121 | __in_z_opt LPCWSTR wzDownloadSource, | ||
122 | __out BOOL* pfRetry, | ||
123 | __out BOOL* pfDownload | ||
124 | ); | ||
125 | static HRESULT CopyPayload( | 119 | static HRESULT CopyPayload( |
126 | __in BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT* pProgress, | 120 | __in BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT* pProgress, |
127 | __in HANDLE hSourceFile, | 121 | __in HANDLE hSourceFile, |
@@ -485,6 +479,9 @@ extern "C" HRESULT ApplyCache( | |||
485 | cacheContext.qwTotalCacheSize = pPlan->qwCacheSizeTotal; | 479 | cacheContext.qwTotalCacheSize = pPlan->qwCacheSizeTotal; |
486 | cacheContext.wzLayoutDirectory = pPlan->sczLayoutDirectory; | 480 | cacheContext.wzLayoutDirectory = pPlan->sczLayoutDirectory; |
487 | 481 | ||
482 | hr = MemAllocArray(reinterpret_cast<LPVOID*>(&cacheContext.rgSearchPaths), sizeof(LPWSTR), BURN_CACHE_MAX_SEARCH_PATHS); | ||
483 | ExitOnNull(cacheContext.rgSearchPaths, hr, E_OUTOFMEMORY, "Failed to allocate cache search paths array."); | ||
484 | |||
488 | for (DWORD i = 0; i < pPlan->cCacheActions; ++i) | 485 | for (DWORD i = 0; i < pPlan->cCacheActions; ++i) |
489 | { | 486 | { |
490 | BURN_CACHE_ACTION* pCacheAction = pPlan->rgCacheActions + i; | 487 | BURN_CACHE_ACTION* pCacheAction = pPlan->rgCacheActions + i; |
@@ -561,6 +558,12 @@ LExit: | |||
561 | 558 | ||
562 | CacheCleanup(FALSE, pPlan->wzBundleId); | 559 | CacheCleanup(FALSE, pPlan->wzBundleId); |
563 | 560 | ||
561 | for (DWORD i = 0; i < cacheContext.cSearchPathsMax; ++i) | ||
562 | { | ||
563 | ReleaseNullStr(cacheContext.rgSearchPaths[i]); | ||
564 | } | ||
565 | ReleaseMem(cacheContext.rgSearchPaths); | ||
566 | |||
564 | UserExperienceOnCacheComplete(pUX, hr); | 567 | UserExperienceOnCacheComplete(pUX, hr); |
565 | return hr; | 568 | return hr; |
566 | } | 569 | } |
@@ -949,17 +952,8 @@ static HRESULT ApplyProcessPayload( | |||
949 | { | 952 | { |
950 | fRetry = FALSE; | 953 | fRetry = FALSE; |
951 | 954 | ||
952 | if (pPayload->pContainer) | 955 | hr = AcquireContainerOrPayload(pContext, NULL, pPackage, pPayload); |
953 | { | 956 | LogExitOnFailure(hr, MSG_FAILED_ACQUIRE_PAYLOAD, "Failed to acquire payload: %ls to working path: %ls", pPayload->sczKey, pPayload->sczUnverifiedPath); |
954 | // TODO: only extract container if payload isn't already extracted | ||
955 | hr = ApplyExtractContainer(pContext, pPayload->pContainer); | ||
956 | ExitOnFailure(hr, "Failed to extract container for payload: %ls", pPayload->sczKey); | ||
957 | } | ||
958 | else | ||
959 | { | ||
960 | hr = AcquireContainerOrPayload(pContext, NULL, pPackage, pPayload); | ||
961 | LogExitOnFailure(hr, MSG_FAILED_ACQUIRE_PAYLOAD, "Failed to acquire payload: %ls to working path: %ls", pPayload->sczKey, pPayload->sczUnverifiedPath); | ||
962 | } | ||
963 | 957 | ||
964 | pContext->qwSuccessfulCacheProgress += pPayload->qwFileSize; | 958 | pContext->qwSuccessfulCacheProgress += pPayload->qwFileSize; |
965 | 959 | ||
@@ -1054,8 +1048,10 @@ static HRESULT LayoutBundle( | |||
1054 | { | 1048 | { |
1055 | HRESULT hr = S_OK; | 1049 | HRESULT hr = S_OK; |
1056 | LPWSTR sczBundlePath = NULL; | 1050 | LPWSTR sczBundlePath = NULL; |
1051 | LPWSTR sczBundleDownloadUrl = NULL; | ||
1057 | LPWSTR sczDestinationPath = NULL; | 1052 | LPWSTR sczDestinationPath = NULL; |
1058 | int nEquivalentPaths = 0; | 1053 | int nEquivalentPaths = 0; |
1054 | BOOTSTRAPPER_CACHE_OPERATION cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE; | ||
1059 | BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT progress = { }; | 1055 | BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT progress = { }; |
1060 | BOOL fRetry = FALSE; | 1056 | BOOL fRetry = FALSE; |
1061 | BOOL fRetryAcquire = FALSE; | 1057 | BOOL fRetryAcquire = FALSE; |
@@ -1096,7 +1092,7 @@ static HRESULT LayoutBundle( | |||
1096 | fRetryAcquire = FALSE; | 1092 | fRetryAcquire = FALSE; |
1097 | progress.fCancel = FALSE; | 1093 | progress.fCancel = FALSE; |
1098 | 1094 | ||
1099 | hr = UserExperienceOnCacheAcquireBegin(pContext->pUX, NULL, NULL, BOOTSTRAPPER_CACHE_OPERATION_COPY, sczBundlePath); | 1095 | hr = UserExperienceOnCacheAcquireBegin(pContext->pUX, NULL, NULL, &sczBundlePath, &sczBundleDownloadUrl, NULL, &cacheOperation); |
1100 | ExitOnRootFailure(hr, "BA aborted cache acquire begin."); | 1096 | ExitOnRootFailure(hr, "BA aborted cache acquire begin."); |
1101 | 1097 | ||
1102 | hr = CopyPayload(&progress, pContext->hSourceEngineFile, sczBundlePath, wzUnverifiedPath); | 1098 | hr = CopyPayload(&progress, pContext->hSourceEngineFile, sczBundlePath, wzUnverifiedPath); |
@@ -1142,6 +1138,7 @@ static HRESULT LayoutBundle( | |||
1142 | 1138 | ||
1143 | LExit: | 1139 | LExit: |
1144 | ReleaseStr(sczDestinationPath); | 1140 | ReleaseStr(sczDestinationPath); |
1141 | ReleaseStr(sczBundleDownloadUrl); | ||
1145 | ReleaseStr(sczBundlePath); | 1142 | ReleaseStr(sczBundlePath); |
1146 | 1143 | ||
1147 | return hr; | 1144 | return hr; |
@@ -1160,11 +1157,16 @@ static HRESULT AcquireContainerOrPayload( | |||
1160 | int nEquivalentPaths = 0; | 1157 | int nEquivalentPaths = 0; |
1161 | LPCWSTR wzPackageOrContainerId = pContainer ? pContainer->sczId : pPackage ? pPackage->sczId : NULL; | 1158 | LPCWSTR wzPackageOrContainerId = pContainer ? pContainer->sczId : pPackage ? pPackage->sczId : NULL; |
1162 | LPCWSTR wzPayloadId = pPayload ? pPayload->sczKey : NULL; | 1159 | LPCWSTR wzPayloadId = pPayload ? pPayload->sczKey : NULL; |
1160 | LPCWSTR wzPayloadContainerId = pPayload && pPayload->pContainer ? pPayload->pContainer->sczId : NULL; | ||
1163 | LPCWSTR wzDestinationPath = pContainer ? pContainer->sczUnverifiedPath: pPayload->sczUnverifiedPath; | 1161 | LPCWSTR wzDestinationPath = pContainer ? pContainer->sczUnverifiedPath: pPayload->sczUnverifiedPath; |
1164 | LPCWSTR wzRelativePath = pContainer ? pContainer->sczFilePath : pPayload->sczFilePath; | 1162 | LPCWSTR wzRelativePath = pContainer ? pContainer->sczFilePath : pPayload->sczFilePath; |
1165 | LPWSTR sczSourceFullPath = NULL; | ||
1166 | BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT progress = { }; | 1163 | BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT progress = { }; |
1164 | BOOL fBeginCalled = FALSE; | ||
1167 | BOOL fRetry = FALSE; | 1165 | BOOL fRetry = FALSE; |
1166 | DWORD dwChosenSearchPath = 0; | ||
1167 | BOOTSTRAPPER_CACHE_OPERATION cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE; | ||
1168 | LPWSTR* pwzDownloadUrl = pContainer ? &pContainer->downloadSource.sczUrl : &pPayload->downloadSource.sczUrl; | ||
1169 | LPWSTR* pwzSourcePath = pContainer ? &pContainer->sczSourcePath : &pPayload->sczSourcePath; | ||
1168 | 1170 | ||
1169 | progress.pCacheContext = pContext; | 1171 | progress.pCacheContext = pContext; |
1170 | progress.pContainer = pContainer; | 1172 | progress.pContainer = pContainer; |
@@ -1173,86 +1175,148 @@ static HRESULT AcquireContainerOrPayload( | |||
1173 | 1175 | ||
1174 | do | 1176 | do |
1175 | { | 1177 | { |
1176 | LPCWSTR wzDownloadUrl = pContainer ? pContainer->downloadSource.sczUrl : pPayload->downloadSource.sczUrl; | ||
1177 | LPCWSTR wzSourcePath = pContainer ? pContainer->sczSourcePath : pPayload->sczSourcePath; | ||
1178 | |||
1179 | BOOL fFoundLocal = FALSE; | 1178 | BOOL fFoundLocal = FALSE; |
1180 | BOOL fCopy = FALSE; | ||
1181 | BOOL fDownload = FALSE; | ||
1182 | 1179 | ||
1180 | pContext->cSearchPaths = 0; | ||
1181 | dwChosenSearchPath = 0; | ||
1183 | fRetry = FALSE; | 1182 | fRetry = FALSE; |
1184 | progress.fCancel = FALSE; | 1183 | progress.fCancel = FALSE; |
1184 | fBeginCalled = TRUE; | ||
1185 | 1185 | ||
1186 | hr = CacheFindLocalSource(wzSourcePath, wzDestinationPath, pContext->pVariables, &fFoundLocal, &sczSourceFullPath); | 1186 | hr = UserExperienceOnCacheAcquireBegin(pContext->pUX, wzPackageOrContainerId, wzPayloadId, pwzSourcePath, pwzDownloadUrl, wzPayloadContainerId, &cacheOperation); |
1187 | ExitOnFailure(hr, "Failed to search local source."); | 1187 | ExitOnRootFailure(hr, "BA aborted cache acquire begin."); |
1188 | |||
1189 | if (fFoundLocal) // the file exists locally, so copy it. | ||
1190 | { | ||
1191 | // If the source path and destination path are different, do the copy (otherwise there's no point). | ||
1192 | hr = PathCompare(sczSourceFullPath, wzDestinationPath, &nEquivalentPaths); | ||
1193 | ExitOnFailure(hr, "Failed to determine if payload source path was equivalent to the destination path."); | ||
1194 | 1188 | ||
1195 | fCopy = (CSTR_EQUAL != nEquivalentPaths); | 1189 | // Skip the Resolving event and probing local paths if the BA already knew it wanted to download or extract. |
1196 | } | 1190 | if (BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD != cacheOperation && |
1197 | else // can't find the file locally, so prompt for source. | 1191 | BOOTSTRAPPER_CACHE_OPERATION_EXTRACT != cacheOperation) |
1198 | { | 1192 | { |
1199 | DWORD dwLogId = pContainer ? (wzPayloadId ? MSG_PROMPT_CONTAINER_PAYLOAD_SOURCE : MSG_PROMPT_CONTAINER_SOURCE) : pPackage ? MSG_PROMPT_PACKAGE_PAYLOAD_SOURCE : MSG_PROMPT_BUNDLE_PAYLOAD_SOURCE; | 1193 | hr = CacheGetLocalSourcePaths(wzRelativePath, *pwzSourcePath, wzDestinationPath, pContext->wzLayoutDirectory, pContext->pVariables, &pContext->rgSearchPaths, &pContext->cSearchPaths); |
1200 | LogId(REPORT_STANDARD, dwLogId, wzPackageOrContainerId ? wzPackageOrContainerId : L"", wzPayloadId ? wzPayloadId : L"", sczSourceFullPath); | 1194 | ExitOnFailure(hr, "Failed to search local source."); |
1201 | 1195 | ||
1202 | hr = PromptForSource(pContext->pUX, wzPackageOrContainerId, wzPayloadId, sczSourceFullPath, wzDownloadUrl, &fRetry, &fDownload); | 1196 | for (DWORD i = 0; i < pContext->cSearchPaths; ++i) |
1197 | { | ||
1198 | // If the file exists locally, choose it. | ||
1199 | if (FileExistsEx(pContext->rgSearchPaths[i], NULL)) | ||
1200 | { | ||
1201 | dwChosenSearchPath = i; | ||
1202 | |||
1203 | fFoundLocal = TRUE; | ||
1204 | break; | ||
1205 | } | ||
1206 | } | ||
1203 | 1207 | ||
1204 | // If the BA requested download then ensure a download url is available (it may have been set | 1208 | if (BOOTSTRAPPER_CACHE_OPERATION_COPY == cacheOperation) |
1205 | // during PromptForSource so we need to check again). | 1209 | { |
1206 | if (fDownload) | 1210 | if (!fFoundLocal) |
1211 | { | ||
1212 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_NONE; | ||
1213 | } | ||
1214 | } | ||
1215 | else | ||
1207 | { | 1216 | { |
1208 | wzDownloadUrl = pContainer ? pContainer->downloadSource.sczUrl : pPayload->downloadSource.sczUrl; | 1217 | if (fFoundLocal) // the file exists locally, so copy it. |
1209 | if (!wzDownloadUrl || !*wzDownloadUrl) | 1218 | { |
1219 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_COPY; | ||
1220 | } | ||
1221 | else if (wzPayloadContainerId) | ||
1222 | { | ||
1223 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_EXTRACT; | ||
1224 | } | ||
1225 | else if (*pwzDownloadUrl && **pwzDownloadUrl) | ||
1210 | { | 1226 | { |
1211 | hr = E_INVALIDARG; | 1227 | cacheOperation = BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD; |
1212 | } | 1228 | } |
1213 | } | 1229 | } |
1214 | 1230 | ||
1215 | // Log the error | 1231 | // Let the BA have a chance to override the action, but their chance to change the source is during begin or complete. |
1216 | LogExitOnFailure(hr, MSG_PAYLOAD_FILE_NOT_PRESENT, "Failed while prompting for source (original path '%ls').", sczSourceFullPath); | 1232 | hr = UserExperienceOnCacheAcquireResolving(pContext->pUX, wzPackageOrContainerId, wzPayloadId, pContext->rgSearchPaths, pContext->cSearchPaths, fFoundLocal, &dwChosenSearchPath, *pwzDownloadUrl, wzPayloadContainerId, &cacheOperation); |
1233 | ExitOnRootFailure(hr, "BA aborted cache acquire resolving."); | ||
1217 | } | 1234 | } |
1218 | 1235 | ||
1219 | if (fCopy) | 1236 | switch (cacheOperation) |
1220 | { | 1237 | { |
1221 | hr = UserExperienceOnCacheAcquireBegin(pContext->pUX, wzPackageOrContainerId, wzPayloadId, BOOTSTRAPPER_CACHE_OPERATION_COPY, sczSourceFullPath); | 1238 | case BOOTSTRAPPER_CACHE_OPERATION_COPY: |
1222 | ExitOnRootFailure(hr, "BA aborted cache acquire begin."); | 1239 | // If the source path and destination path are different, do the copy (otherwise there's no point). |
1240 | hr = PathCompare(pContext->rgSearchPaths[dwChosenSearchPath], wzDestinationPath, &nEquivalentPaths); | ||
1241 | ExitOnFailure(hr, "Failed to determine if payload paths were equivalent, source: %ls, destination: %ls.", pContext->rgSearchPaths[dwChosenSearchPath], wzDestinationPath); | ||
1223 | 1242 | ||
1224 | hr = CopyPayload(&progress, INVALID_HANDLE_VALUE, sczSourceFullPath, wzDestinationPath); | 1243 | if (CSTR_EQUAL != nEquivalentPaths) |
1225 | // Error handling happens after sending complete message to BA. | 1244 | { |
1245 | hr = CopyPayload(&progress, INVALID_HANDLE_VALUE, pContext->rgSearchPaths[dwChosenSearchPath], wzDestinationPath); | ||
1246 | // Error handling happens after sending complete message to BA. | ||
1247 | |||
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 | } | ||
1254 | } | ||
1226 | 1255 | ||
1227 | // We successfully copied from a source location, set that as the last used source. | 1256 | fBeginCalled = FALSE; |
1228 | if (SUCCEEDED(hr)) | 1257 | UserExperienceOnCacheAcquireComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr, &fRetry); |
1258 | if (fRetry) | ||
1229 | { | 1259 | { |
1230 | CacheSetLastUsedSource(pContext->pVariables, sczSourceFullPath, wzRelativePath); | 1260 | hr = S_OK; |
1231 | } | 1261 | } |
1232 | } | ||
1233 | else if (fDownload) | ||
1234 | { | ||
1235 | hr = UserExperienceOnCacheAcquireBegin(pContext->pUX, wzPackageOrContainerId, wzPayloadId, BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD, wzDownloadUrl); | ||
1236 | ExitOnRootFailure(hr, "BA aborted cache download payload begin."); | ||
1237 | 1262 | ||
1263 | ExitOnFailure(hr, "Failed to acquire payload from: '%ls' to working path: '%ls'", pContext->rgSearchPaths[dwChosenSearchPath], wzDestinationPath); | ||
1264 | |||
1265 | break; | ||
1266 | case BOOTSTRAPPER_CACHE_OPERATION_DOWNLOAD: | ||
1238 | hr = DownloadPayload(&progress, wzDestinationPath); | 1267 | hr = DownloadPayload(&progress, wzDestinationPath); |
1239 | // Error handling happens after sending complete message to BA. | 1268 | // Error handling happens after sending complete message to BA. |
1240 | } | ||
1241 | 1269 | ||
1242 | if (fCopy || fDownload) | 1270 | fBeginCalled = FALSE; |
1243 | { | 1271 | UserExperienceOnCacheAcquireComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr, &fRetry); |
1272 | if (fRetry) | ||
1273 | { | ||
1274 | hr = S_OK; | ||
1275 | } | ||
1276 | |||
1277 | ExitOnFailure(hr, "Failed to acquire payload from: '%ls' to working path: '%ls'", *pwzDownloadUrl, wzDestinationPath); | ||
1278 | |||
1279 | break; | ||
1280 | case BOOTSTRAPPER_CACHE_OPERATION_EXTRACT: | ||
1281 | Assert(pPayload->pContainer); | ||
1282 | |||
1283 | hr = ApplyExtractContainer(pContext, pPayload->pContainer); | ||
1284 | // Error handling happens after sending complete message to BA. | ||
1285 | |||
1286 | fBeginCalled = FALSE; | ||
1287 | UserExperienceOnCacheAcquireComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr, &fRetry); | ||
1288 | if (fRetry) | ||
1289 | { | ||
1290 | hr = S_OK; | ||
1291 | } | ||
1292 | |||
1293 | ExitOnFailure(hr, "Failed to extract container for payload: %ls", wzPayloadId); | ||
1294 | |||
1295 | break; | ||
1296 | case BOOTSTRAPPER_CACHE_OPERATION_NONE: | ||
1297 | hr = E_FILENOTFOUND; | ||
1298 | LogErrorId(hr, MSG_RESOLVE_SOURCE_FAILED, wzPayloadId, pPackage ? pPackage->sczId : NULL, pContainer ? pContainer->sczId : NULL); | ||
1299 | |||
1300 | fBeginCalled = FALSE; | ||
1244 | UserExperienceOnCacheAcquireComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr, &fRetry); | 1301 | UserExperienceOnCacheAcquireComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr, &fRetry); |
1245 | if (fRetry) | 1302 | if (fRetry) |
1246 | { | 1303 | { |
1247 | hr = S_OK; | 1304 | hr = S_OK; |
1248 | } | 1305 | } |
1306 | |||
1307 | ExitOnFailure(hr, "Failed to resolve source, payload: %ls, package: %ls, container: %ls", wzPayloadId, pPackage ? pPackage->sczId : NULL, pContainer ? pContainer->sczId : NULL); | ||
1308 | |||
1309 | break; | ||
1249 | } | 1310 | } |
1250 | ExitOnFailure(hr, "Failed to acquire payload from: '%ls' to working path: '%ls'", fCopy ? sczSourceFullPath : wzDownloadUrl, wzDestinationPath); | ||
1251 | } while (fRetry); | 1311 | } while (fRetry); |
1252 | ExitOnFailure(hr, "Failed to find external payload to cache."); | ||
1253 | 1312 | ||
1254 | LExit: | 1313 | LExit: |
1255 | ReleaseStr(sczSourceFullPath); | 1314 | if (fBeginCalled) |
1315 | { | ||
1316 | UserExperienceOnCacheAcquireComplete(pContext->pUX, wzPackageOrContainerId, wzPayloadId, hr, &fRetry); | ||
1317 | } | ||
1318 | |||
1319 | pContext->cSearchPathsMax = max(pContext->cSearchPaths, pContext->cSearchPathsMax); | ||
1256 | 1320 | ||
1257 | return hr; | 1321 | return hr; |
1258 | } | 1322 | } |
@@ -1355,48 +1419,6 @@ LExit: | |||
1355 | return hr; | 1419 | return hr; |
1356 | } | 1420 | } |
1357 | 1421 | ||
1358 | static HRESULT PromptForSource( | ||
1359 | __in BURN_USER_EXPERIENCE* pUX, | ||
1360 | __in_z LPCWSTR wzPackageOrContainerId, | ||
1361 | __in_z_opt LPCWSTR wzPayloadId, | ||
1362 | __in_z LPCWSTR wzLocalSource, | ||
1363 | __in_z_opt LPCWSTR wzDownloadSource, | ||
1364 | __inout BOOL* pfRetry, | ||
1365 | __inout BOOL* pfDownload | ||
1366 | ) | ||
1367 | { | ||
1368 | HRESULT hr = S_OK; | ||
1369 | BOOTSTRAPPER_RESOLVESOURCE_ACTION action = BOOTSTRAPPER_RESOLVESOURCE_ACTION_NONE; | ||
1370 | |||
1371 | hr = UserExperienceOnResolveSource(pUX, wzPackageOrContainerId, wzPayloadId, wzLocalSource, wzDownloadSource, &action); | ||
1372 | if (FAILED(hr)) | ||
1373 | { | ||
1374 | ExitFunction(); | ||
1375 | } | ||
1376 | |||
1377 | switch (action) | ||
1378 | { | ||
1379 | case BOOTSTRAPPER_RESOLVESOURCE_ACTION_NONE: | ||
1380 | hr = E_FILENOTFOUND; | ||
1381 | break; | ||
1382 | |||
1383 | case BOOTSTRAPPER_RESOLVESOURCE_ACTION_RETRY: | ||
1384 | *pfRetry = TRUE; | ||
1385 | break; | ||
1386 | |||
1387 | case BOOTSTRAPPER_RESOLVESOURCE_ACTION_DOWNLOAD: | ||
1388 | *pfDownload = TRUE; | ||
1389 | break; | ||
1390 | |||
1391 | default: | ||
1392 | hr = E_INVALIDARG; | ||
1393 | break; | ||
1394 | } | ||
1395 | |||
1396 | LExit: | ||
1397 | return hr; | ||
1398 | } | ||
1399 | |||
1400 | static HRESULT CopyPayload( | 1422 | static HRESULT CopyPayload( |
1401 | __in BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT* pProgress, | 1423 | __in BURN_CACHE_ACQUIRE_PROGRESS_CONTEXT* pProgress, |
1402 | __in HANDLE hSourceFile, | 1424 | __in HANDLE hSourceFile, |