Saltar al contenido principal

UpdateManager class

Provides functionality for checking for updates, downloading updates, and applying updates to the current application.

class UpdateManager

Constructors

ConstructorSummary
constructorCreate a new UpdateManager instance.

constructor(urlOrPath, options, locator)

constructor(urlOrPath: string, options?: UpdateOptions, locator?: VelopackLocatorConfig)

Create a new UpdateManager instance.

Parameters

NameTypeDescription
urlOrPathstringLocation of the update server or path to the local update directory.
optionsUpdateOptionsOptional extra configuration for update manager. (optional)
locatorVelopackLocatorConfigOverride the default locator configuration (usually used for testing / mocks). (optional)

Methods

MethodSummary
checkForUpdatesAsyncChecks for updates, returning None if there are none available. If there are updates available, this method will return an
downloadUpdateAsyncDownloads the specified updates to the local app packages directory. Progress is reported back to the caller via an optional Sender.
getAppIdReturns the currently installed app id.
getCurrentVersionReturns the currently installed version of the app.
getUpdatePendingRestartReturns an VelopackAsset object if there is an update downloaded which still needs to be applied.
isPortableReturns whether the app is in portable mode. On Windows this can be true or false.
waitExitThenApplyUpdateThis will launch the Velopack updater and tell it to wait for this program to exit gracefully.

checkForUpdatesAsync()

checkForUpdatesAsync(): Promise<UpdateInfo | null>

Checks for updates, returning None 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 Promise<UpdateInfo \| null>

downloadUpdateAsync(update, progress)

downloadUpdateAsync(update: UpdateInfo, progress?: object): Promise<void>

Downloads the specified updates to the local app packages directory. Progress is reported back to the caller via an optional Sender. 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

NameTypeDescription
updateUpdateInfo
progressobject(optional)

Returns Promise<void>

getAppId()

getAppId(): string

Returns the currently installed app id.

Returns string

getCurrentVersion()

getCurrentVersion(): string

Returns the currently installed version of the app.

Returns string

getUpdatePendingRestart()

getUpdatePendingRestart(): VelopackAsset | null

Returns an VelopackAsset object if there is an update downloaded which still needs to be applied. You can pass the VelopackAsset object to waitExitThenApplyUpdate to apply the update.

Returns VelopackAsset \| null

isPortable()

isPortable(): boolean

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.

Returns boolean

waitExitThenApplyUpdate(update, silent, restart, restartArgs)

waitExitThenApplyUpdate(update: VelopackAsset | UpdateInfo, silent?: boolean, restart?: boolean, restartArgs?: string[]): void

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

NameTypeDescription
updateVelopackAsset | UpdateInfo
silentboolean(optional)
restartboolean(optional)
restartArgsstring[](optional)

Returns void


Generated from velopack 1.1.1