Skip to content

How updates are installed

Alexey Golub edited this page May 30, 2018 · 3 revisions

In Onova, update installation is performed in two high-level steps:

  1. Prepare the update -- done in PrepareUpdateAsync().
  2. Apply the update -- started by LaunchUpdater().

Prepare the update

In this step, Onova downloads and extracts the update package. This process is the most time-consuming one and is usually done in a background thread.

The steps are as following:

  1. Create temporary folder structure in %localappdata%/Onova/{AssemblyName}.
  2. Download the package to a temporary directory, using specified IPackageResolver.
  3. Extract the package contents to a temporary directory, using specified IPackageExtractor.
  4. Delete the downloaded package after the contents have been extracted.
  5. Extract Onova.Updater.exe (external updater) from library's resources to a temporary directory, also renaming it according to the assembly name ({AssemblyName}.Updater.exe).

Apply the update

Since the application cannot overwrite its own files while it's running, an external updater (Onova.Updater) is used. Calling LaunchUpdater simply launches the updater, passing required command line arguments. It also determines whether the updater needs to be launched with elevated privileges by checking if it can write to the target directory.

External updater

Once the updater is launched, it waits for the application to exit and copies the new files.

The steps are as following:

  1. Wait until application exits, using process ID.
  2. Copy the contents of the downloaded package to the updatee's directory, overwriting target files.
  3. Delete package contents from temporary storage.
  4. If instructed to, re-launch the application.

Onova.Updater writes its own log file for diagnostic purposes, it's saved next to the executable, at %localappdata%/Onova/{AssemblyName}/Log.txt.

Cleaning up

Onova deletes temporary files once it's done using them, but there are two that cannot be deleted during update -- the external updater executable and the log file. If you wish to delete everything you can call the Cleanup() method (e.g. at startup) which deletes the entire temporary directory.