Class DesktopAppUpdaterProvider
- Assembly
- VpnHood.AppUi.Hosting.Desktop.Daemon.dll
Provides the app's update on a desktop installed from the website, in the service: the notice's Update and Install, and the automatic update's part.
public abstract class DesktopAppUpdaterProvider : IAppUpdaterProvider
- Inheritance
-
DesktopAppUpdaterProvider
- Implements
- Derived
- Inherited Members
Remarks
The feed is the one the install's publish.json names. Update downloads the feed's package into the install's
updates folder; Install hands it to the platform's installer, whose install stops this service, replaces it and starts
the new version, so an Install that ends with this service still here installed nothing. The automatic update is
the platform's updater, a script apart from the service, which shares the updates folder; a run of it that could not
reach the server leaves a file, and the service may run it again after a later connect, while automatic updates are
on.
Constructors
DesktopAppUpdaterProvider(string, string, Uri, Version)
Provides the app's update on a desktop installed from the website, in the service: the notice's Update and Install, and the automatic update's part.
protected DesktopAppUpdaterProvider(string updatesPath, string missedPath, Uri updateInfoUrl, Version appVersion)
Parameters
updatesPathstringThe install's updates folder.
missedPathstringThe file the updater leaves while its last run could not reach the server.
updateInfoUrlUriThe feed.
appVersionVersionThis app's version.
Remarks
The feed is the one the install's publish.json names. Update downloads the feed's package into the install's
updates folder; Install hands it to the platform's installer, whose install stops this service, replaces it and starts
the new version, so an Install that ends with this service still here installed nothing. The automatic update is
the platform's updater, a script apart from the service, which shares the updates folder; a run of it that could not
reach the server leaves a file, and the service may run it again after a later connect, while automatic updates are
on.
Fields
MissedFileName
The name of the file the updater leaves while its last run could not reach the server.
protected const string MissedFileName = "update.missed"
Field Value
Properties
HasOwnScreen
Gets a value indicating whether a store's own screen shows the update, where the person decides: the check opens it by itself after a delay, the store's offer keeps the feed's notice away, and its "none" before a connect waits for the connect; otherwise, the app's notice offers the update, which starts at the person's press, or by itself where the channel's automatic update is on (IsAutomaticUpdateSupported).
public bool HasOwnScreen { get; }
Property Value
Remarks
It is false: the app's notice shows the update.
IsAutomaticUpdateSupported
Gets a value indicating whether the app turns the channel's automatic update on and off, as a desktop's own updater does; a store's is the store's own setting.
public bool IsAutomaticUpdateSupported { get; }
Property Value
Remarks
It is true: the platform's updater is the automatic update.
IsInstalling
Gets a value indicating whether an install the app runs itself, and waits on, is under way, which stops the app once it puts the new version in; the app refuses connects meanwhile.
public bool IsInstalling { get; }
Property Value
Remarks
It is a desktop's: a store's install and Android's package installer are the system's, which stops the app itself.
UpdateInfoUrl
Gets the feed, as the install's publish.json names it.
public Uri UpdateInfoUrl { get; }
Property Value
Methods
Check(AppRelease?, IUiContext?, CancellationToken)
Asks the channel for an update now, which may take the network.
public Task<AppUpdateState> Check(AppRelease? feedRelease, IUiContext? uiContext, CancellationToken cancellationToken)
Parameters
feedReleaseAppReleaseThe feed's newer release, or null.
uiContextIUiContextThe app's window, or null where none is open.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<AppUpdateState>
A task whose result is the update as it stands.
Remarks
It reads only this service's own update and the updates folder: no network. The token is not read.
Exceptions
- UiContextNotAvailableException
uiContextis null, and the channel needs a window, as a store's.- TimeoutException
The store did not answer its query in time, as Google Play's.
- NotSupportedException
The store needs a desktop window, which the UI context is not, as the Microsoft Store's.
- OperationCanceledException
cancellationTokenwas canceled.
CompleteUpdate(AppRelease?, IUiContext?, CancellationToken)
Installs the downloaded update: the person's Install, where the channel stops after the download.
public Task CompleteUpdate(AppRelease? feedRelease, IUiContext? uiContext, CancellationToken cancellationToken)
Parameters
feedReleaseAppReleaseThe feed's newer release, or null.
uiContextIUiContextThe app's window, or null where none is open.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once the install has started, or, where the system must first let the app install apps (IsInstallPermissionNeeded), once the system's page for it is open.
Remarks
The token is not read.
Exceptions
- NotSupportedException
The channel has no such step.
- InvalidOperationException
There is no newer version, or its update is not downloaded.
- UiContextNotAvailableException
The channel needs a compatible UI context, as Android's, and
uiContextis null or not one.- OperationCanceledException
cancellationTokenwas canceled.- InvalidOperationException
There is no newer release, or it has not been downloaded.
GetState(AppRelease?)
Gets the update as it stands, which the notice reads whenever it refreshes: it takes no network. With no release, what an earlier one left behind goes.
public AppUpdateState GetState(AppRelease? feedRelease)
Parameters
feedReleaseAppReleaseThe feed's newer release, or null.
Returns
- AppUpdateState
The update's state; none where the channel does not update this copy, whose notice keeps the feed's link.
IsAutomaticUpdateOn(CancellationToken)
Gets whether the automatic update is on, read where the platform keeps it each time, as its installer and its own tools change it too.
public abstract Task<bool> IsAutomaticUpdateOn(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Remarks
The platform's updater runs by itself where its timer or task is on, as its installer left it.
Exceptions
- NotSupportedException
The channel has no such switch.
- OperationCanceledException
cancellationTokenwas canceled.- InvalidOperationException
The platform's tool could not be started.
ReadUpdateInfoUrl(string)
Reads the feed a publish.json names.
protected static Uri? ReadUpdateInfoUrl(string publishInfoPath)
Parameters
publishInfoPathstringThe
publish.json.
Returns
Exceptions
- InvalidDataException
The
UpdateInfoUrlproperty is null.
ResumeUpdate(IUiContext, CancellationToken)
Brings back the screen of an update the person started and left before it finished; the app asks it with a window in front, apart from the checks' interval.
public Task<bool> ResumeUpdate(IUiContext uiContext, CancellationToken cancellationToken)
Parameters
uiContextIUiContextThe app's window.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Remarks
It is false: nothing here waits for the person. The token is not read.
Exceptions
- TimeoutException
The store did not answer its query in time, as Google Play's.
- OperationCanceledException
cancellationTokenwas canceled.
RunInstaller(string)
Runs the platform's installer on a package.
protected abstract Task<string?> RunInstaller(string packagePath)
Parameters
packagePathstringThe package.
Returns
- Task<string>
A task whose result is null once its install is stopping this service, which the install goes on without; else why it installed nothing.
Exceptions
- InvalidOperationException
The installer could not be started.
RunTool(string, IReadOnlyList<string>, CancellationToken)
Runs a platform tool to its end.
protected static Task<(int ExitCode, string Output, string Error)> RunTool(string fileName, IReadOnlyList<string> arguments, CancellationToken cancellationToken)
Parameters
fileNamestringThe tool.
argumentsIReadOnlyList<string>Its arguments.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<(int ExitCode, string Output, string Error)>
A task whose result is the tool's exit code and what it wrote to its output and error streams.
Exceptions
- InvalidOperationException
The tool could not be run.
- OperationCanceledException
cancellationTokenwas canceled.
RunUpdater(CancellationToken)
Starts a run of the platform's updater now, as its timer or task does, which goes on by itself.
protected abstract Task RunUpdater(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once the run is asked for.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.- InvalidOperationException
The platform's tool could not be started, or could not start the run.
SetAutomaticUpdate(bool, CancellationToken)
Turns the automatic update on or off; off stops only the automatic update, as the person's check, Update and Install still work.
public abstract Task SetAutomaticUpdate(bool isOn, CancellationToken cancellationToken)
Parameters
isOnbooltrue to turn it on.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once it is set.
Remarks
It turns the timer or the task on or off, which the installers keep at an update.
Exceptions
- NotSupportedException
The channel has no such switch.
- InvalidOperationException
The platform's command failed, as Linux's systemctl.
- OperationCanceledException
cancellationTokenwas canceled.
StartUpdate(AppRelease?, IUiContext?, CancellationToken)
Starts the update: the person's Update, or the store's screen the check opens.
public Task StartUpdate(AppRelease? feedRelease, IUiContext? uiContext, CancellationToken cancellationToken)
Parameters
feedReleaseAppReleaseThe feed's newer release, or null.
uiContextIUiContextThe app's window, or null where none is open.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes at the channel's own stage: once the download has begun, where the app downloads the update; once the store's page is open, as the App Store's; once the store's update flow has ended, installed or dismissed, as Google Play's; or once the store's own download and install have ended, as the Microsoft Store's.
Remarks
The token is not read.
Exceptions
- InvalidOperationException
There is no newer version to update to, the store has none to show, the store's update failed, or the release's package is not on https, as the desktop's refuses.
- NotSupportedException
This copy cannot take the release, as the website's APK refuses a package that is not on https, or the store needs a desktop window, which the UI context is not, as the Microsoft Store's.
- TimeoutException
The store did not answer its query in time, as Google Play's.
- UiContextNotAvailableException
uiContextis null, and the channel needs a window, as a store's.- OperationCanceledException
cancellationTokenwas canceled.- InvalidOperationException
There is no newer release, or its package is neither on https nor on this machine.