Skip to main content

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

ConstructorSummary
UpdateManagerCreate a new UpdateManager instance for a local or remote directory of releases.
UpdateManagerCreate 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

NameDescription
urlOrPathLocation of the http update server or the local update directory path containing releases.
optionsOptional extra configuration for update manager.
locatorOverride 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

NameDescription
pUpdateSourceThe source to use for retrieving feed and downloading assets.
optionsOptional extra configuration for update manager.
locatorOverride the default locator configuration (usually used for testing / mocks).

Methods

MethodSummary
IsPortableReturns whether the app is in portable mode. On Windows this can be true or false. On MacOS and Linux this will always be true.
GetCurrentVersionReturns the currently installed version of the app.
GetAppIdReturns the currently installed app id.
UpdatePendingRestartReturns 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.
CheckForUpdatesChecks 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.
DownloadUpdatesDownloads 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.
WaitExitThenApplyUpdatesThis 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.
WaitExitThenApplyUpdatesThis 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.
UnsafeApplyUpdatesThis 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

NameDescription
updateThe update to download.
progressA callback to report progress to.
pUserDataA 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

NameDescription
assetThe UpdateInfo object for the update to apply.
silentIf true, the updater will not show any UI.
restartIf true, the app will be restarted after the update is applied.
restartArgsThe 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

NameDescription
assetThe update to apply.
silentIf true, the updater will not show any UI.
restartIf true, the app will be restarted after the update is applied.
restartArgsThe 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

NameDescription
assetThe update to apply.
silentIf true, the updater will not show any UI.
waitPidThe process ID to wait for before applying updates. If 0, the updater will not wait.
restartIf true, the app will be restarted after the update is applied.
restartArgsThe arguments to pass to the app when it is restarted.

Generated from Velopack (C++ headers)