From 62b32cd6f21292c73dae8d5cfcd3a1cb13a1fd7d Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 19 Apr 2021 17:32:32 -0500 Subject: Replace OnResolveSource with OnCacheAcquireResolving. Update balretry to have a separate type for container vs payload. #3640 --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 24 ++- src/WixToolset.Mba.Core/EventArgs.cs | 143 +++++++------ .../IBootstrapperApplication.cs | 100 +++++---- .../IDefaultBootstrapperApplication.cs | 19 +- src/balutil/balretry.cpp | 223 +++++++++++++-------- src/balutil/balutil.vcxproj | 8 +- src/balutil/inc/BAFunctions.h | 2 +- src/balutil/inc/BalBaseBAFunctions.h | 23 ++- src/balutil/inc/BalBaseBAFunctionsProc.h | 2 +- src/balutil/inc/BalBaseBootstrapperApplication.h | 36 ++-- .../inc/BalBaseBootstrapperApplicationProc.h | 16 +- src/balutil/inc/IBootstrapperApplication.h | 50 +++-- src/balutil/inc/balretry.h | 37 ++-- src/balutil/packages.config | 4 +- src/bextutil/bextutil.vcxproj | 8 +- src/bextutil/packages.config | 4 +- src/mbanative/mbanative.vcxproj | 8 +- src/mbanative/packages.config | 4 +- src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj | 8 +- src/test/BalUtilUnitTest/packages.config | 4 +- src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj | 8 +- src/test/BextUtilUnitTest/packages.config | 4 +- 22 files changed, 444 insertions(+), 291 deletions(-) diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index b6c0dd0d..79cbfa86 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -146,7 +146,7 @@ namespace WixToolset.Mba.Core public event EventHandler CacheAcquireProgress; /// - public event EventHandler ResolveSource; + public event EventHandler CacheAcquireResolving; /// public event EventHandler CacheAcquireComplete; @@ -736,12 +736,12 @@ namespace WixToolset.Mba.Core } /// - /// Called by the engine, raises the event. + /// Called by the engine, raises the event. /// /// Additional arguments for this event. - protected virtual void OnResolveSource(ResolveSourceEventArgs args) + protected virtual void OnCacheAcquireResolving(CacheAcquireResolvingEventArgs args) { - EventHandler handler = this.ResolveSource; + EventHandler handler = this.CacheAcquireResolving; if (null != handler) { handler(this, args); @@ -1126,9 +1126,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectBegin(bool fInstalled, int cPackages, ref bool fCancel) + int IBootstrapperApplication.OnDetectBegin(bool fCached, bool fInstalled, int cPackages, ref bool fCancel) { - DetectBeginEventArgs args = new DetectBeginEventArgs(fInstalled, cPackages, fCancel); + DetectBeginEventArgs args = new DetectBeginEventArgs(fCached, fInstalled, cPackages, fCancel); this.OnDetectBegin(args); fCancel = args.Cancel; @@ -1400,11 +1400,12 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnCacheAcquireBegin(string wzPackageOrContainerId, string wzPayloadId, CacheOperation operation, string wzSource, ref bool fCancel) + int IBootstrapperApplication.OnCacheAcquireBegin(string wzPackageOrContainerId, string wzPayloadId, string wzSource, string wzDownloadUrl, string wzPayloadContainerId, CacheOperation recommendation, ref CacheOperation action, ref bool fCancel) { - CacheAcquireBeginEventArgs args = new CacheAcquireBeginEventArgs(wzPackageOrContainerId, wzPayloadId, operation, wzSource, fCancel); + CacheAcquireBeginEventArgs args = new CacheAcquireBeginEventArgs(wzPackageOrContainerId, wzPayloadId, wzSource, wzDownloadUrl, wzPayloadContainerId, recommendation, action, fCancel); this.OnCacheAcquireBegin(args); + action = args.Action; fCancel = args.Cancel; return args.HResult; } @@ -1418,11 +1419,12 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnResolveSource(string wzPackageOrContainerId, string wzPayloadId, string wzLocalSource, string wzDownloadSource, BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, ref BOOTSTRAPPER_RESOLVESOURCE_ACTION action, ref bool fCancel) + int IBootstrapperApplication.OnCacheAcquireResolving(string wzPackageOrContainerId, string wzPayloadId, string[] searchPaths, int cSearchPaths, bool fFoundLocal, int dwRecommendedSearchPath, string wzDownloadUrl, string wzPayloadContainerId, CacheResolveOperation recommendation, ref int dwChosenSearchPath, ref CacheResolveOperation action, ref bool fCancel) { - ResolveSourceEventArgs args = new ResolveSourceEventArgs(wzPackageOrContainerId, wzPayloadId, wzLocalSource, wzDownloadSource, action, recommendation, fCancel); - this.OnResolveSource(args); + CacheAcquireResolvingEventArgs args = new CacheAcquireResolvingEventArgs(wzPackageOrContainerId, wzPayloadId, searchPaths, fFoundLocal, dwRecommendedSearchPath, wzDownloadUrl, wzPayloadContainerId, recommendation, dwChosenSearchPath, action, fCancel); + this.OnCacheAcquireResolving(args); + dwChosenSearchPath = args.ChosenSearchPath; action = args.Action; fCancel = args.Cancel; return args.HResult; diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index 7e7cbd11..ee89b583 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -122,6 +122,31 @@ namespace WixToolset.Mba.Core public T Action { get; set; } } + /// + /// Base class for cancellable action BA classes. + /// + [Serializable] + public abstract class CancellableActionEventArgs : CancellableHResultEventArgs + { + /// + public CancellableActionEventArgs(bool cancelRecommendation, T recommendation, T action) + : base(cancelRecommendation) + { + this.Recommendation = recommendation; + this.Action = action; + } + + /// + /// Gets the recommended action from the engine. + /// + public T Recommendation { get; private set; } + + /// + /// Gets or sets the action to be performed. This is passed back to the engine. + /// + public T Action { get; set; } + } + /// /// Additional arguments used when startup has begun. /// @@ -196,24 +221,25 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the overall detection phase has begun. + /// Event arguments for /// [Serializable] public class DetectBeginEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// - /// Specifies whether the bundle is installed. - /// The number of packages to detect. - /// The recommendation from the engine. - public DetectBeginEventArgs(bool installed, int packageCount, bool cancelRecommendation) + /// + public DetectBeginEventArgs(bool cached, bool installed, int packageCount, bool cancelRecommendation) : base(cancelRecommendation) { + this.Cached = cached; this.Installed = installed; this.PackageCount = packageCount; } + /// + /// Gets whether the bundle is cached. + /// + public bool Cached { get; private set; } + /// /// Gets whether the bundle is installed. /// @@ -290,6 +316,7 @@ namespace WixToolset.Mba.Core : base(cancelRecommendation) { this.UpdateLocation = updateLocation; + this.Skip = skipRecommendation; } /// @@ -1242,6 +1269,8 @@ namespace WixToolset.Mba.Core /// public UnregisterBeginEventArgs(bool keepRegistration, bool forceKeepRegistration) { + this.KeepRegistration = keepRegistration; + this.ForceKeepRegistration = forceKeepRegistration; } /// @@ -1288,21 +1317,20 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine begins to acquire containers or payloads. + /// EventArgs for . /// [Serializable] - public class CacheAcquireBeginEventArgs : CancellableHResultEventArgs + public class CacheAcquireBeginEventArgs : CancellableActionEventArgs { - /// - /// Creates a new instance of the class. - /// - public CacheAcquireBeginEventArgs(string packageOrContainerId, string payloadId, CacheOperation operation, string source, bool cancelRecommendation) - : base(cancelRecommendation) + /// + public CacheAcquireBeginEventArgs(string packageOrContainerId, string payloadId, string source, string downloadUrl, string payloadContainerId, CacheOperation recommendation, CacheOperation action, bool cancelRecommendation) + : base(cancelRecommendation, recommendation, action) { this.PackageOrContainerId = packageOrContainerId; this.PayloadId = payloadId; - this.Operation = operation; this.Source = source; + this.DownloadUrl = downloadUrl; + this.PayloadContainerId = payloadContainerId; } /// @@ -1316,25 +1344,28 @@ namespace WixToolset.Mba.Core public string PayloadId { get; private set; } /// - /// Gets the cache acquire operation. + /// Gets the source of the container or payload. /// - public CacheOperation Operation { get; private set; } + public string Source { get; private set; } /// - /// Gets the source of the container or payload. + /// Gets the optional URL to download container or payload. /// - public string Source { get; private set; } + public string DownloadUrl { get; private set; } + + /// + /// Gets the optional identity of the container that contains the payload being acquired. + /// + public string PayloadContainerId { get; private set; } } /// - /// Additional arguments used when the engine acquires some part of a container or payload. + /// EventArgs for . /// [Serializable] public class CacheAcquireProgressEventArgs : CancellableHResultEventArgs { - /// - /// Creates a new instance of the class. - /// + /// public CacheAcquireProgressEventArgs(string packageOrContainerId, string payloadId, long progress, long total, int overallPercentage, bool cancelRecommendation) : base(cancelRecommendation) { @@ -1372,14 +1403,12 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used when the engine completes the acquisition of a container or payload. + /// EventArgs for . /// [Serializable] public class CacheAcquireCompleteEventArgs : ActionEventArgs { - /// - /// Creates a new instance of the class. - /// + /// public CacheAcquireCompleteEventArgs(string packageOrContainerId, string payloadId, int hrStatus, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION recommendation, BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION action) : base(hrStatus, recommendation, action) { @@ -1729,62 +1758,64 @@ namespace WixToolset.Mba.Core } /// - /// Additional arguments used by the engine to allow the BA to change the source - /// using or . + /// EventArgs for . /// [Serializable] - public class ResolveSourceEventArgs : CancellableHResultEventArgs + public class CacheAcquireResolvingEventArgs : CancellableActionEventArgs { - /// - /// Creates a new instance of the class. - /// - /// The identity of the package or container that requires source. - /// The identity of the payload that requires source. - /// The current path used for source resolution. - /// Optional URL to download container or payload. - /// The recommended action from the engine. - /// The action to perform. - /// The recommendation from the engine. - public ResolveSourceEventArgs(string packageOrContainerId, string payloadId, string localSource, string downloadSource, BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, BOOTSTRAPPER_RESOLVESOURCE_ACTION action, bool cancelRecommendation) - : base(cancelRecommendation) + /// + public CacheAcquireResolvingEventArgs(string packageOrContainerId, string payloadId, string[] searchPaths, bool foundLocal, int recommendedSearchPath, string downloadUrl, string payloadContainerId, CacheResolveOperation recommendation, int chosenSearchPath, CacheResolveOperation action, bool cancel) + : base(cancel, recommendation, action) { this.PackageOrContainerId = packageOrContainerId; this.PayloadId = payloadId; - this.LocalSource = localSource; - this.DownloadSource = downloadSource; - this.Recommendation = recommendation; - this.Action = action; + this.SearchPaths = searchPaths; + this.FoundLocal = foundLocal; + this.RecommendedSearchPath = recommendedSearchPath; + this.DownloadUrl = downloadUrl; + this.PayloadContainerId = payloadContainerId; + this.ChosenSearchPath = chosenSearchPath; } /// - /// Gets the identity of the package or container that requires source. + /// Gets the identity of the package or container that is being acquired. /// public string PackageOrContainerId { get; private set; } /// - /// Gets the identity of the payload that requires source. + /// Gets the identity of the payload that is being acquired. /// public string PayloadId { get; private set; } /// - /// Gets the current path used for source resolution. + /// Gets the search paths used for source resolution. /// - public string LocalSource { get; private set; } + public string[] SearchPaths { get; private set; } + + /// + /// Gets whether indicates that a file was found at that search path. + /// + public bool FoundLocal { get; private set; } + + /// + /// When is true, the index to for the recommended local file. + /// + public int RecommendedSearchPath { get; private set; } /// /// Gets the optional URL to download container or payload. /// - public string DownloadSource { get; private set; } + public string DownloadUrl { get; private set; } /// - /// Gets the recommended action from the engine. + /// Gets the optional identity of the container that contains the payload being acquired. /// - public BOOTSTRAPPER_RESOLVESOURCE_ACTION Recommendation { get; private set; } + public string PayloadContainerId { get; private set; } /// - /// Gets or sets the action to perform. + /// Gets or sets the index to to use when is set to . /// - public BOOTSTRAPPER_RESOLVESOURCE_ACTION Action { get; set; } + public int ChosenSearchPath { get; set; } } /// diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index 14cb8fd5..88c65674 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -44,13 +44,10 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnDetectBegin( + [MarshalAs(UnmanagedType.Bool)] bool fCached, [MarshalAs(UnmanagedType.Bool)] bool fInstalled, [MarshalAs(UnmanagedType.U4)] int cPackages, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel @@ -540,32 +537,22 @@ namespace WixToolset.Mba.Core /// /// See . /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireBegin( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.U4)] CacheOperation operation, [MarshalAs(UnmanagedType.LPWStr)] string wzSource, + [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadUrl, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadContainerId, + [MarshalAs(UnmanagedType.U4)] CacheOperation recommendation, + [MarshalAs(UnmanagedType.I4)] ref CacheOperation action, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); /// /// See . /// - /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireProgress( @@ -578,37 +565,28 @@ namespace WixToolset.Mba.Core ); /// - /// See . + /// See . /// - /// - /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] - int OnResolveSource( + int OnCacheAcquireResolving( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, - [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, - [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, - BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, - ref BOOTSTRAPPER_RESOLVESOURCE_ACTION action, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3, ArraySubType = UnmanagedType.LPWStr), In] string[] searchPaths, + [MarshalAs(UnmanagedType.U4)] int cSearchPaths, + [MarshalAs(UnmanagedType.Bool)] bool fFoundLocal, + [MarshalAs(UnmanagedType.U4)] int dwRecommendedSearchPath, + [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadUrl, + [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadContainerId, + [MarshalAs(UnmanagedType.I4)] CacheResolveOperation recommendation, + [MarshalAs(UnmanagedType.U4)] ref int dwChosenSearchPath, + [MarshalAs(UnmanagedType.I4)] ref CacheResolveOperation action, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); /// /// See . /// - /// - /// - /// - /// - /// - /// [PreserveSig] [return: MarshalAs(UnmanagedType.I4)] int OnCacheAcquireComplete( @@ -1419,19 +1397,55 @@ namespace WixToolset.Mba.Core public enum CacheOperation { /// - /// Container or payload is being copied. + /// There is no source available. + /// + None, + + /// + /// Copy the payload or container from the chosen local source. /// Copy, /// - /// Container or payload is being downloaded. + /// Download the payload or container using the download URL. /// Download, /// - /// Container or payload is being extracted. + /// Extract the payload from the container. + /// + Extract, + } + + /// + /// The source to be used to acquire a container or payload. + /// + public enum CacheResolveOperation + { + /// + /// There is no source available. + /// + None, + + /// + /// Copy the payload or container from the chosen local source. /// - Extract + Local, + + /// + /// Download the payload or container from the download URL. + /// + Download, + + /// + /// Extract the payload from the container. + /// + Container, + + /// + /// Look again for the payload or container locally. + /// + Retry, } /// @@ -1637,7 +1651,7 @@ namespace WixToolset.Mba.Core } /// - /// The available actions for . + /// The available actions for . /// public enum BOOTSTRAPPER_RESOLVESOURCE_ACTION { diff --git a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 269d4955..03f94d37 100644 --- a/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -30,12 +30,16 @@ namespace WixToolset.Mba.Core event EventHandler BeginMsiTransactionComplete; /// - /// Fired when the engine has begun acquiring the installation sources. + /// Fired when the engine has begun acquiring the payload or container. + /// The BA can change the source using + /// or . /// event EventHandler CacheAcquireBegin; /// - /// Fired when the engine has completed the acquisition of the installation sources. + /// Fired when the engine has completed the acquisition of the payload or container. + /// The BA can change the source using + /// or . /// event EventHandler CacheAcquireComplete; @@ -44,6 +48,11 @@ namespace WixToolset.Mba.Core /// event EventHandler CacheAcquireProgress; + /// + /// Fired by the engine to allow the BA to override the acquisition action. + /// + event EventHandler CacheAcquireResolving; + /// /// Fired when the engine has begun caching the installation sources. /// @@ -284,12 +293,6 @@ namespace WixToolset.Mba.Core /// event EventHandler RegisterComplete; - /// - /// Fired by the engine to allow the BA to change the source - /// using or . - /// - event EventHandler ResolveSource; - /// /// Fired when the engine is about to rollback an MSI transaction. /// diff --git a/src/balutil/balretry.cpp b/src/balutil/balretry.cpp index d95d86b2..9d8abd6d 100644 --- a/src/balutil/balretry.cpp +++ b/src/balutil/balretry.cpp @@ -2,23 +2,33 @@ #include "precomp.h" +typedef enum BALRETRY_TYPE +{ + BALRETRY_TYPE_CACHE_CONTAINER, + BALRETRY_TYPE_CACHE_PAYLOAD, + BALRETRY_TYPE_EXECUTE, +} BALRETRY_TYPE; + struct BALRETRY_INFO { - LPWSTR sczId; // package or container id. - LPWSTR sczPayloadId; // optional payload id. + LPWSTR sczId; DWORD cRetries; DWORD dwLastError; }; static DWORD vdwMaxRetries = 0; static DWORD vdwTimeout = 0; -static BALRETRY_INFO vrgRetryInfo[2]; +static BALRETRY_INFO vrgRetryInfo[3]; // prototypes static BOOL IsActiveRetryEntry( __in BALRETRY_TYPE type, - __in_z LPCWSTR wzPackageId, - __in_z_opt LPCWSTR wzPayloadId + __in_z LPCWSTR sczId + ); + +static HRESULT StartActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR sczId ); @@ -39,7 +49,6 @@ DAPI_(void) BalRetryUninitialize() for (DWORD i = 0; i < countof(vrgRetryInfo); ++i) { ReleaseStr(vrgRetryInfo[i].sczId); - ReleaseStr(vrgRetryInfo[i].sczPayloadId); memset(vrgRetryInfo + i, 0, sizeof(BALRETRY_INFO)); } @@ -48,34 +57,32 @@ DAPI_(void) BalRetryUninitialize() } -DAPI_(void) BalRetryStartPackage( - __in BALRETRY_TYPE type, - __in_z_opt LPCWSTR wzPackageId, +DAPI_(void) BalRetryStartContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, __in_z_opt LPCWSTR wzPayloadId ) { - if (!wzPackageId || !*wzPackageId) + if (!wzContainerOrPackageId && !wzPayloadId) { - ReleaseNullStr(vrgRetryInfo[type].sczId); - ReleaseNullStr(vrgRetryInfo[type].sczPayloadId); + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_CONTAINER].sczId); + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_PAYLOAD].sczId); } - else if (IsActiveRetryEntry(type, wzPackageId, wzPayloadId)) + else if (wzPayloadId) { - ++vrgRetryInfo[type].cRetries; - ::Sleep(vdwTimeout); + StartActiveRetryEntry(BALRETRY_TYPE_CACHE_PAYLOAD, wzPayloadId); } else { - StrAllocString(&vrgRetryInfo[type].sczId, wzPackageId, 0); - if (wzPayloadId) - { - StrAllocString(&vrgRetryInfo[type].sczPayloadId, wzPayloadId, 0); - } - - vrgRetryInfo[type].cRetries = 0; + StartActiveRetryEntry(BALRETRY_TYPE_CACHE_CONTAINER, wzContainerOrPackageId); } +} - vrgRetryInfo[type].dwLastError = ERROR_SUCCESS; + +DAPI_(void) BalRetryStartPackage( + __in_z LPCWSTR wzPackageId + ) +{ + StartActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId); } @@ -84,87 +91,112 @@ DAPI_(void) BalRetryErrorOccurred( __in DWORD dwError ) { - if (IsActiveRetryEntry(BALRETRY_TYPE_CACHE, wzPackageId, NULL)) + if (IsActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId)) { - vrgRetryInfo[BALRETRY_TYPE_CACHE].dwLastError = dwError; + vrgRetryInfo[BALRETRY_TYPE_EXECUTE].dwLastError = dwError; } - else if (IsActiveRetryEntry(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL)) +} + + +DAPI_(HRESULT) BalRetryEndContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, + __in_z_opt LPCWSTR wzPayloadId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ) +{ + HRESULT hr = S_OK; + BALRETRY_TYPE type = BALRETRY_TYPE_CACHE_PAYLOAD; + LPCWSTR wzId = NULL; + + if (!wzContainerOrPackageId && !wzPayloadId) { - vrgRetryInfo[BALRETRY_TYPE_EXECUTE].dwLastError = dwError; + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_CONTAINER].sczId); + ReleaseNullStr(vrgRetryInfo[BALRETRY_TYPE_CACHE_PAYLOAD].sczId); + ExitFunction(); + } + else if (wzPayloadId) + { + type = BALRETRY_TYPE_CACHE_PAYLOAD; + wzId = wzPayloadId; + } + else + { + type = BALRETRY_TYPE_CACHE_CONTAINER; + wzId = wzContainerOrPackageId; } + + if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzId)) + { + // Retry on all errors except the following. + if (HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) != hrError && + BG_E_NETWORK_DISCONNECTED != hrError && + HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) != hrError && + HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED) != hrError) + { + *pfRetry = TRUE; + } + } + +LExit: + return hr; } DAPI_(HRESULT) BalRetryEndPackage( - __in BALRETRY_TYPE type, - __in_z_opt LPCWSTR wzPackageId, - __in_z_opt LPCWSTR wzPayloadId, + __in_z LPCWSTR wzPackageId, __in HRESULT hrError, __inout BOOL* pfRetry ) { HRESULT hr = S_OK; + BALRETRY_TYPE type = BALRETRY_TYPE_EXECUTE; if (!wzPackageId || !*wzPackageId) { ReleaseNullStr(vrgRetryInfo[type].sczId); - ReleaseNullStr(vrgRetryInfo[type].sczPayloadId); } - else if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzPackageId, wzPayloadId)) + else if (FAILED(hrError) && vrgRetryInfo[type].cRetries < vdwMaxRetries && IsActiveRetryEntry(type, wzPackageId)) { - if (BALRETRY_TYPE_CACHE == type) + // If the service is out of whack, just try again. + if (HRESULT_FROM_WIN32(ERROR_INSTALL_SERVICE_FAILURE) == hrError) { - // Retry on all errors except the following. - if (HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT) != hrError && - BG_E_NETWORK_DISCONNECTED != hrError && - HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) != hrError && - HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED) != hrError) - { - *pfRetry = TRUE; - } + *pfRetry = TRUE; } - else if (BALRETRY_TYPE_EXECUTE == type) + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE) == hrError) { - // If the service is out of whack, just try again. - if (HRESULT_FROM_WIN32(ERROR_INSTALL_SERVICE_FAILURE) == hrError) - { - *pfRetry = TRUE; - } - else if (HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE) == hrError) - { - DWORD dwError = vrgRetryInfo[type].dwLastError; - - // If we failed with one of these specific error codes, then retry since - // we've seen these have a high success of succeeding on retry. - if (1303 == dwError || - 1304 == dwError || - 1306 == dwError || - 1307 == dwError || - 1309 == dwError || - 1310 == dwError || - 1311 == dwError || - 1312 == dwError || - 1316 == dwError || - 1317 == dwError || - 1321 == dwError || - 1335 == dwError || - 1402 == dwError || - 1406 == dwError || - 1606 == dwError || - 1706 == dwError || - 1719 == dwError || - 1723 == dwError || - 1923 == dwError || - 1931 == dwError) - { - *pfRetry = TRUE; - } - } - else if (HRESULT_FROM_WIN32(ERROR_INSTALL_ALREADY_RUNNING) == hrError) + DWORD dwError = vrgRetryInfo[type].dwLastError; + + // If we failed with one of these specific error codes, then retry since + // we've seen these have a high success of succeeding on retry. + if (1303 == dwError || + 1304 == dwError || + 1306 == dwError || + 1307 == dwError || + 1309 == dwError || + 1310 == dwError || + 1311 == dwError || + 1312 == dwError || + 1316 == dwError || + 1317 == dwError || + 1321 == dwError || + 1335 == dwError || + 1402 == dwError || + 1406 == dwError || + 1606 == dwError || + 1706 == dwError || + 1719 == dwError || + 1723 == dwError || + 1923 == dwError || + 1931 == dwError) { *pfRetry = TRUE; } } + else if (HRESULT_FROM_WIN32(ERROR_INSTALL_ALREADY_RUNNING) == hrError) + { + *pfRetry = TRUE; + } } return hr; @@ -175,17 +207,40 @@ DAPI_(HRESULT) BalRetryEndPackage( static BOOL IsActiveRetryEntry( __in BALRETRY_TYPE type, - __in_z LPCWSTR wzPackageId, - __in_z_opt LPCWSTR wzPayloadId + __in_z LPCWSTR sczId ) { BOOL fActive = FALSE; - fActive = vrgRetryInfo[type].sczId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPackageId, -1, vrgRetryInfo[type].sczId, -1); - if (fActive && wzPayloadId) // if a payload id was provided ensure it matches. + fActive = vrgRetryInfo[type].sczId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, sczId, -1, vrgRetryInfo[type].sczId, -1); + + return fActive; +} + +static HRESULT StartActiveRetryEntry( + __in BALRETRY_TYPE type, + __in_z LPCWSTR sczId + ) +{ + HRESULT hr = S_OK; + + if (!sczId || !*sczId) { - fActive = vrgRetryInfo[type].sczPayloadId && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzPayloadId, -1, vrgRetryInfo[type].sczPayloadId, -1); + ReleaseNullStr(vrgRetryInfo[type].sczId); } + else if (IsActiveRetryEntry(type, sczId)) + { + ++vrgRetryInfo[type].cRetries; + ::Sleep(vdwTimeout); + } + else + { + hr = StrAllocString(&vrgRetryInfo[type].sczId, sczId, 0); - return fActive; + vrgRetryInfo[type].cRetries = 0; + } + + vrgRetryInfo[type].dwLastError = ERROR_SUCCESS; + + return hr; } diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 6d31f9ba..a47e994f 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/src/balutil/inc/BAFunctions.h b/src/balutil/inc/BAFunctions.h index 66852efa..07f7a750 100644 --- a/src/balutil/inc/BAFunctions.h +++ b/src/balutil/inc/BAFunctions.h @@ -42,7 +42,7 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGEBEGIN, BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREBEGIN, BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS, - BA_FUNCTIONS_MESSAGE_ONRESOLVESOURCE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONRESOLVESOURCE, + BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRERESOLVING = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING, BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE, BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYBEGIN, BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEVERIFYCOMPLETE, diff --git a/src/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 0164269c..ca727f49 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -90,6 +90,7 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fCached*/, __in BOOL /*fInstalled*/, __in DWORD /*cPackages*/, __inout BOOL* /*pfCancel*/ @@ -385,8 +386,11 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnCacheAcquireBegin( __in_z LPCWSTR /*wzPackageOrContainerId*/, __in_z_opt LPCWSTR /*wzPayloadId*/, - __in BOOTSTRAPPER_CACHE_OPERATION /*operation*/, __in_z LPCWSTR /*wzSource*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_OPERATION /*recommendation*/, + __inout BOOTSTRAPPER_CACHE_OPERATION* /*pAction*/, __inout BOOL* /*pfCancel*/ ) { @@ -405,13 +409,18 @@ public: // IBootstrapperApplication return S_OK; } - virtual STDMETHODIMP OnResolveSource( - __in_z LPCWSTR /*wzPackageOrContainerId*/, + virtual STDMETHODIMP OnCacheAcquireResolving( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, __in_z_opt LPCWSTR /*wzPayloadId*/, - __in_z LPCWSTR /*wzLocalSource*/, - __in_z_opt LPCWSTR /*wzDownloadSource*/, - __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* /*pAction*/, + __in_z LPCWSTR* /*rgSearchPaths*/, + __in DWORD /*cSearchPaths*/, + __in BOOL /*fFoundLocal*/, + __in DWORD /*dwRecommendedSearchPath*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION /*recommendation*/, + __inout DWORD* /*pdwChosenSearchPath*/, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* /*pAction*/, __inout BOOL* /*pfCancel*/ ) { diff --git a/src/balutil/inc/BalBaseBAFunctionsProc.h b/src/balutil/inc/BalBaseBAFunctionsProc.h index e1de800a..7e89fe83 100644 --- a/src/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/balutil/inc/BalBaseBAFunctionsProc.h @@ -77,7 +77,7 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONCACHEPACKAGEBEGIN: case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREBEGIN: case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIREPROGRESS: - case BA_FUNCTIONS_MESSAGE_ONRESOLVESOURCE: + case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRERESOLVING: case BA_FUNCTIONS_MESSAGE_ONCACHEACQUIRECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYBEGIN: case BA_FUNCTIONS_MESSAGE_ONCACHEVERIFYCOMPLETE: diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index c9211e0f..3d3e4ffa 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -87,6 +87,7 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fCached*/, __in BOOL /*fInstalled*/, __in DWORD /*cPackages*/, __inout BOOL* pfCancel @@ -442,14 +443,17 @@ public: // IBootstrapperApplication } virtual STDMETHODIMP OnCacheAcquireBegin( - __in_z LPCWSTR wzPackageOrContainerId, + __in_z_opt LPCWSTR wzPackageOrContainerId, __in_z_opt LPCWSTR wzPayloadId, - __in BOOTSTRAPPER_CACHE_OPERATION /*operation*/, __in_z LPCWSTR /*wzSource*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_OPERATION /*recommendation*/, + __inout BOOTSTRAPPER_CACHE_OPERATION* /*pAction*/, __inout BOOL* pfCancel ) { - BalRetryStartPackage(BALRETRY_TYPE_CACHE, wzPackageOrContainerId, wzPayloadId); + BalRetryStartContainerOrPayload(wzPackageOrContainerId, wzPayloadId); *pfCancel |= CheckCanceled(); return S_OK; } @@ -488,13 +492,18 @@ public: // IBootstrapperApplication return hr; } - virtual STDMETHODIMP OnResolveSource( - __in_z LPCWSTR /*wzPackageOrContainerId*/, + virtual STDMETHODIMP OnCacheAcquireResolving( + __in_z_opt LPCWSTR /*wzPackageOrContainerId*/, __in_z_opt LPCWSTR /*wzPayloadId*/, - __in_z LPCWSTR /*wzLocalSource*/, - __in_z_opt LPCWSTR /*wzDownloadSource*/, - __in BOOTSTRAPPER_RESOLVESOURCE_ACTION /*recommendation*/, - __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* /*pAction*/, + __in_z LPCWSTR* /*rgSearchPaths*/, + __in DWORD /*cSearchPaths*/, + __in BOOL /*fFoundLocal*/, + __in DWORD /*dwRecommendedSearchPath*/, + __in_z_opt LPCWSTR /*wzDownloadUrl*/, + __in_z_opt LPCWSTR /*wzPayloadContainerId*/, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION /*recommendation*/, + __inout DWORD* /*pdwChosenSearchPath*/, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* /*pAction*/, __inout BOOL* pfCancel ) { @@ -518,7 +527,7 @@ public: // IBootstrapperApplication ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); } - hr = BalRetryEndPackage(BALRETRY_TYPE_CACHE, wzPackageOrContainerId, wzPayloadId, hrStatus, &fRetry); + hr = BalRetryEndContainerOrPayload(wzPackageOrContainerId, wzPayloadId, hrStatus, &fRetry); ExitOnFailure(hr, "BalRetryEndPackage for cache failed"); if (fRetry) @@ -599,7 +608,7 @@ public: // IBootstrapperApplication // Only track retry on execution (not rollback). if (fExecute) { - BalRetryStartPackage(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL); + BalRetryStartPackage(wzPackageId); } m_fRollingBack = !fExecute; @@ -700,7 +709,7 @@ public: // IBootstrapperApplication ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT)); } - hr = BalRetryEndPackage(BALRETRY_TYPE_EXECUTE, wzPackageId, NULL, hrStatus, &fRetry); + hr = BalRetryEndPackage(wzPackageId, hrStatus, &fRetry); ExitOnFailure(hr, "BalRetryEndPackage for execute failed"); if (fRetry) @@ -951,6 +960,9 @@ protected: m_fApplying = FALSE; m_fRollingBack = FALSE; + m_dwProgressPercentage = 0; + m_dwOverallProgressPercentage = 0; + BalRetryInitialize(dwRetryCount, dwRetryTimeout); } diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index d8a6590b..42ffeb79 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -15,7 +15,7 @@ static HRESULT BalBaseBAProcOnDetectBegin( __inout BA_ONDETECTBEGIN_RESULTS* pResults ) { - return pBA->OnDetectBegin(pArgs->fInstalled, pArgs->cPackages, &pResults->fCancel); + return pBA->OnDetectBegin(pArgs->fCached, pArgs->fInstalled, pArgs->cPackages, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectComplete( @@ -303,7 +303,7 @@ static HRESULT BalBaseBAProcOnCacheAcquireBegin( __inout BA_ONCACHEACQUIREBEGIN_RESULTS* pResults ) { - return pBA->OnCacheAcquireBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->operation, pArgs->wzSource, &pResults->fCancel); + return pBA->OnCacheAcquireBegin(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->wzSource, pArgs->wzDownloadUrl, pArgs->wzPayloadContainerId, pArgs->recommendation, &pResults->action, &pResults->fCancel); } static HRESULT BalBaseBAProcOnCacheAcquireProgress( @@ -315,13 +315,13 @@ static HRESULT BalBaseBAProcOnCacheAcquireProgress( return pBA->OnCacheAcquireProgress(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->dw64Progress, pArgs->dw64Total, pArgs->dwOverallPercentage, &pResults->fCancel); } -static HRESULT BalBaseBAProcOnResolveSource( +static HRESULT BalBaseBAProcOnCacheAcquireResolving( __in IBootstrapperApplication* pBA, - __in BA_ONRESOLVESOURCE_ARGS* pArgs, - __inout BA_ONRESOLVESOURCE_RESULTS* pResults + __in BA_ONCACHEACQUIRERESOLVING_ARGS* pArgs, + __inout BA_ONCACHEACQUIRERESOLVING_RESULTS* pResults ) { - return pBA->OnResolveSource(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->recommendation, &pResults->action, &pResults->fCancel); + return pBA->OnCacheAcquireResolving(pArgs->wzPackageOrContainerId, pArgs->wzPayloadId, pArgs->rgSearchPaths, pArgs->cSearchPaths, pArgs->fFoundLocal, pArgs->dwRecommendedSearchPath, pArgs->wzDownloadUrl, pArgs->wzPayloadContainerId, pArgs->recommendation, &pResults->dwChosenSearchPath, &pResults->action, &pResults->fCancel); } static HRESULT BalBaseBAProcOnCacheAcquireComplete( @@ -713,8 +713,8 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIREPROGRESS: hr = BalBaseBAProcOnCacheAcquireProgress(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; - case BOOTSTRAPPER_APPLICATION_MESSAGE_ONRESOLVESOURCE: - hr = BalBaseBAProcOnResolveSource(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRERESOLVING: + hr = BalBaseBAProcOnCacheAcquireResolving(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; case BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEACQUIRECOMPLETE: hr = BalBaseBAProcOnCacheAcquireComplete(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index ed70d8fe..8fcdd318 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -21,6 +21,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A // OnDetectBegin - called when the engine begins detection. STDMETHOD(OnDetectBegin)( + __in BOOL fCached, __in BOOL fInstalled, __in DWORD cPackages, __inout BOOL* pfCancel @@ -279,14 +280,20 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnCacheAcquireBegin - called when the engine begins copying or - // downloading a payload to the working folder. + // OnCacheAcquireBegin - called when the engine begins acquiring a payload or container. + // + // Notes: + // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() + // to update the source location before returning. // STDMETHOD(OnCacheAcquireBegin)( __in_z_opt LPCWSTR wzPackageOrContainerId, __in_z_opt LPCWSTR wzPayloadId, - __in BOOTSTRAPPER_CACHE_OPERATION operation, __in_z LPCWSTR wzSource, + __in_z_opt LPCWSTR wzDownloadUrl, + __in_z_opt LPCWSTR wzPayloadContainerId, + __in BOOTSTRAPPER_CACHE_OPERATION recommendation, + __inout BOOTSTRAPPER_CACHE_OPERATION* pAction, __inout BOOL* pfCancel ) = 0; @@ -302,27 +309,38 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOL* pfCancel ) = 0; - // OnResolveSource - called when a payload or container cannot be found locally. + // OnCacheAcquireResolving - called to allow the BA to override the acquisition action for the payload or container. // // Parameters: + // wzPackageOrContainerId will be NULL when resolving a layout-only payload. // wzPayloadId will be NULL when resolving a container. - // wzDownloadSource will be NULL if the container or payload does not provide a DownloadURL. + // wzDownloadUrl will be NULL if the container or payload does not provide a DownloadURL. + // wzPayloadContainerId will not be NULL if acquiring a payload that is in a container. // - // Notes: - // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() - // to update the source location before returning BOOTSTRAPPER_RESOLVESOURCE_ACTION_RETRY or BOOTSTRAPPER_RESOLVESOURCE_ACTION_DOWNLOAD. - STDMETHOD(OnResolveSource)( - __in_z LPCWSTR wzPackageOrContainerId, + // rgSearchPaths are the search paths used for source resolution. + // fFoundLocal is TRUE when dwRecommendedSearchPath indicates that the file was found. + // dwRecommendedSearchPath is the index into rgSearchPaths for the recommended local file. + // + STDMETHOD(OnCacheAcquireResolving)( + __in_z_opt LPCWSTR wzPackageOrContainerId, __in_z_opt LPCWSTR wzPayloadId, - __in_z LPCWSTR wzLocalSource, - __in_z_opt LPCWSTR wzDownloadSource, - __in BOOTSTRAPPER_RESOLVESOURCE_ACTION recommendation, - __inout BOOTSTRAPPER_RESOLVESOURCE_ACTION* pAction, + __in_z LPCWSTR* rgSearchPaths, + __in DWORD cSearchPaths, + __in BOOL fFoundLocal, + __in DWORD dwRecommendedSearchPath, + __in_z_opt LPCWSTR wzDownloadUrl, + __in_z_opt LPCWSTR wzPayloadContainerId, + __in BOOTSTRAPPER_CACHE_RESOLVE_OPERATION recommendation, + __inout DWORD* pdwChosenSearchPath, + __inout BOOTSTRAPPER_CACHE_RESOLVE_OPERATION* pAction, __inout BOOL* pfCancel ) = 0; - // OnCacheAcquireComplete - called after the engine copied or downloaded - // a payload to the working folder. + // OnCacheAcquireComplete - called after the engine acquired the payload or container. + // + // Notes: + // It is expected the BA may call IBootstrapperEngine::SetLocalSource() or IBootstrapperEngine::SetDownloadSource() + // to update the source location before returning BOOTSTRAPPER_CACHEACQUIRECOMPLETE_ACTION_RETRY. // STDMETHOD(OnCacheAcquireComplete)( __in_z_opt LPCWSTR wzPackageOrContainerId, diff --git a/src/balutil/inc/balretry.h b/src/balutil/inc/balretry.h index 040ab4ae..35282a7e 100644 --- a/src/balutil/inc/balretry.h +++ b/src/balutil/inc/balretry.h @@ -6,12 +6,6 @@ extern "C" { #endif -typedef enum BALRETRY_TYPE -{ - BALRETRY_TYPE_CACHE, - BALRETRY_TYPE_EXECUTE, -} BALRETRY_TYPE; - /******************************************************************* BalRetryInitialize - initialize the retry count and timeout between retries (in milliseconds). @@ -33,9 +27,7 @@ DAPI_(void) BalRetryUninitialize(); wait the specified timeout. ********************************************************************/ DAPI_(void) BalRetryStartPackage( - __in BALRETRY_TYPE type, - __in_z_opt LPCWSTR wzPackageId, - __in_z_opt LPCWSTR wzPayloadId + __in_z LPCWSTR wzPackageId ); /******************************************************************* @@ -43,17 +35,34 @@ DAPI_(void) BalRetryStartPackage( to consider. ********************************************************************/ DAPI_(void) BalRetryErrorOccurred( - __in_z_opt LPCWSTR wzPackageId, + __in_z LPCWSTR wzPackageId, __in DWORD dwError ); /******************************************************************* - BalRetryEndPackage - returns IDRETRY is a retry is recommended or - IDNOACTION if a retry is not recommended. + BalRetryEndPackage - returns TRUE if a retry is recommended. ********************************************************************/ DAPI_(HRESULT) BalRetryEndPackage( - __in BALRETRY_TYPE type, - __in_z_opt LPCWSTR wzPackageId, + __in_z LPCWSTR wzPackageId, + __in HRESULT hrError, + __inout BOOL* pfRetry + ); + +/******************************************************************* + BalRetryStartContainerOrPayload - call when a container or payload + begins to be acquired. If the target is being retried, + the function will wait the specified timeout. +********************************************************************/ +DAPI_(void) BalRetryStartContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, + __in_z_opt LPCWSTR wzPayloadId + ); + +/******************************************************************* + BalRetryEndContainerOrPayload - returns TRUE if a retry is recommended. +********************************************************************/ +DAPI_(HRESULT) BalRetryEndContainerOrPayload( + __in_z_opt LPCWSTR wzContainerOrPackageId, __in_z_opt LPCWSTR wzPayloadId, __in HRESULT hrError, __inout BOOL* pfRetry diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 0a0e5748..de70fed1 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 5007afb8..c8671f3b 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 0a0e5748..de70fed1 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 0f2e6ee0..729d5df2 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -2,11 +2,11 @@ - + - + @@ -96,7 +96,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index a6397667..b5ba712e 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj index 7fe93b60..95d7ed5f 100644 --- a/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj +++ b/src/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj @@ -3,9 +3,9 @@ - + - + Debug @@ -69,7 +69,7 @@ - - + + \ No newline at end of file diff --git a/src/test/BalUtilUnitTest/packages.config b/src/test/BalUtilUnitTest/packages.config index b8befee3..49b76211 100644 --- a/src/test/BalUtilUnitTest/packages.config +++ b/src/test/BalUtilUnitTest/packages.config @@ -3,8 +3,8 @@ - - + + diff --git a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj index ee676f28..886e3c2c 100644 --- a/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj +++ b/src/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj @@ -3,9 +3,9 @@ - + - + Debug @@ -68,7 +68,7 @@ - - + + \ No newline at end of file diff --git a/src/test/BextUtilUnitTest/packages.config b/src/test/BextUtilUnitTest/packages.config index b8befee3..49b76211 100644 --- a/src/test/BextUtilUnitTest/packages.config +++ b/src/test/BextUtilUnitTest/packages.config @@ -3,8 +3,8 @@ - - + + -- cgit v1.2.3-55-g6feb