UpdateManager class
Provides functionality for checking for updates, downloading updates, and applying updates to the current application.
class UpdateManager
Remarks
This class is the main entry point for interacting with Velopack.
Constructors
| Constructor | Summary |
|---|---|
UpdateManager | Create a new UpdateManager instance for a local or remote directory of releases. |
UpdateManager | Create a new UpdateManager instance with any update source (built-in or custom). The UpdateManager takes ownership of the source. |
UpdateManager(urlOrPath, options, locator)
UpdateManager(std::string const& urlOrPath, Velopack::UpdateOptions const* options = nullptr, Velopack::VelopackLocatorConfig const* locator = nullptr);
Create a new UpdateManager instance for a local or remote directory of releases.
Parameters
| Name | Description |
|---|---|
urlOrPath | Location of the http update server or the local update directory path containing releases. |
options | Optional extra configuration for update manager. |
locator | Override the default locator configuration (usually used for testing / mocks). |
UpdateManager(pUpdateSource, options, locator)
template<typename T, typename = std::enable_if_t<std::is_base_of_v<IUpdateSourcePointer,T>>>
UpdateManager(std::unique_ptr<T> pUpdateSource, Velopack::UpdateOptions const* options = nullptr, Velopack::VelopackLocatorConfig const* locator = nullptr);
Create a new UpdateManager instance with any update source (built-in or custom). The UpdateManager takes ownership of the source.
Parameters
| Name | Description |
|---|---|
pUpdateSource | The source to use for retrieving feed and downloading assets. |
options | Optional extra configuration for update manager. |
locator | Override the default locator configuration (usually used for testing / mocks). |
Methods
| Method | Summary |
|---|---|
IsPortable | Returns whether the app is in portable mode. On Windows this can be true or false. On MacOS and Linux this will always be true. |
GetCurrentVersion | Returns the currently installed version of the app. |
GetAppId | Returns the currently installed app id. |
UpdatePendingRestart | Returns a VelopackAsset object if there is an update downloaded which still needs to be applied. You can pass this object to WaitExitThenApplyUpdates to apply the update. |
CheckForUpdates | Checks for updates, returning null if there are none available. If there are updates available, this method will return an UpdateInfo object containing the latest available release, and any delta updates that can be applied if they are available. |
DownloadUpdates | Downloads the specified updates to the local app packages directory. Progress is reported back to the caller via an optional callback. This function will acquire a global update lock so may fail if there is already another update operation in progress.If the update contains delta packages and the delta feature is enabled this method will attempt to unpack and prepare them.If there is no delta update available, or there is an error preparing delta packages, this method will fall back to downloading the full version of the update. |
WaitExitThenApplyUpdates | This will launch the Velopack updater and tell it to wait for this program to exit gracefully. You should then clean up any state and exit your app. The updater will apply updates and then optionally restart your app. The updater will only wait for 60 seconds before giving up. |
WaitExitThenApplyUpdates | This will launch the Velopack updater and tell it to wait for this program to exit gracefully. You should then clean up any state and exit your app. The updater will apply updates and then optionally restart your app. The updater will only wait for 60 seconds before giving up. |
UnsafeApplyUpdates | This will launch the Velopack updater and optionally wait for a program to exit gracefully. This method is unsafe because it does not necessarily wait for any / the correct process to exit before applying updates. The WaitExitThenApplyUpdates method is recommended for most use cases. If waitPid is 0, the updater will not wait for any process to exit before applying updates (Not Recommended). |
IsPortable()
bool IsPortable() noexcept;
Returns whether the app is in portable mode. On Windows this can be true or false. On MacOS and Linux this will always be true.
GetCurrentVersion()
std::string GetCurrentVersion() noexcept;
Returns the currently installed version of the app.
GetAppId()
std::string GetAppId() noexcept;
Returns the currently installed app id.
UpdatePendingRestart()
std::optional<VelopackAsset> UpdatePendingRestart() noexcept;
Returns a VelopackAsset object if there is an update downloaded which still needs to be applied. You can pass this object to WaitExitThenApplyUpdates to apply the update.
Returns A VelopackAsset object if there is a pending update, otherwise null.
CheckForUpdates()
std::optional<UpdateInfo> CheckForUpdates();
Checks for updates, returning null if there are none available. If there are updates available, this method will return an UpdateInfo object containing the latest available release, and any delta updates that can be applied if they are available.
Returns An UpdateInfo object if there is an update available, otherwise null.
DownloadUpdates(update, progress, pUserData)
void DownloadUpdates(Velopack::UpdateInfo const& update, vpkc_progress_callback_t progress = nullptr, void* pUserData = 0);
Downloads the specified updates to the local app packages directory. Progress is reported back to the caller via an optional callback. This function will acquire a global update lock so may fail if there is already another update operation in progress.If the update contains delta packages and the delta feature is enabled this method will attempt to unpack and prepare them.If there is no delta update available, or there is an error preparing delta packages, this method will fall back to downloading the full version of the update.
Parameters
| Name | Description |
|---|---|
update | The update to download. |
progress | A callback to report progress to. |
pUserData | A pointer to user data that will be passed to the progress callback. |
WaitExitThenApplyUpdates(asset, silent, restart, restartArgs)
void WaitExitThenApplyUpdates(Velopack::UpdateInfo const& asset, bool silent = false, bool restart = true, std::vector<std::string> restartArgs = {});
This will launch the Velopack updater and tell it to wait for this program to exit gracefully. You should then clean up any state and exit your app. The updater will apply updates and then optionally restart your app. The updater will only wait for 60 seconds before giving up.
Parameters
| Name | Description |
|---|---|
asset | The UpdateInfo object for the update to apply. |
silent | If true, the updater will not show any UI. |
restart | If true, the app will be restarted after the update is applied. |
restartArgs | The arguments to pass to the app when it is restarted. |
WaitExitThenApplyUpdates(asset, silent, restart, restartArgs)
void WaitExitThenApplyUpdates(Velopack::VelopackAsset const& asset, bool silent = false, bool restart = true, std::vector<std::string> restartArgs = {});
This will launch the Velopack updater and tell it to wait for this program to exit gracefully. You should then clean up any state and exit your app. The updater will apply updates and then optionally restart your app. The updater will only wait for 60 seconds before giving up.
Parameters
| Name | Description |
|---|---|
asset | The update to apply. |
silent | If true, the updater will not show any UI. |
restart | If true, the app will be restarted after the update is applied. |
restartArgs | The arguments to pass to the app when it is restarted. |
UnsafeApplyUpdates(asset, silent, waitPid, restart, restartArgs)
void UnsafeApplyUpdates(Velopack::VelopackAsset const& asset, bool silent, uint32_t waitPid, bool restart, std::vector<std::string> restartArgs);
This will launch the Velopack updater and optionally wait for a program to exit gracefully. This method is unsafe because it does not necessarily wait for any / the correct process to exit before applying updates. The WaitExitThenApplyUpdates method is recommended for most use cases. If waitPid is 0, the updater will not wait for any process to exit before applying updates (Not Recommended).
Parameters
| Name | Description |
|---|---|
asset | The update to apply. |
silent | If true, the updater will not show any UI. |
waitPid | The process ID to wait for before applying updates. If 0, the updater will not wait. |
restart | If true, the app will be restarted after the update is applied. |
restartArgs | The arguments to pass to the app when it is restarted. |
Generated from Velopack (C++ headers)