GitBase class
Namespace: Velopack.Sources
Base class to provide some shared implementation between sources which download releases from a Git repository.
public abstract class GitBase<T> : IUpdateSource
Implements: IUpdateSource
Constructors
| Constructor | Summary |
|---|---|
GitBase | Base constructor. |
GitBase(repoUrl, accessToken, prerelease, downloader)
protected GitBase(string repoUrl, string? accessToken, bool prerelease, IFileDownloader? downloader = null)
Base constructor.
Parameters
| Name | Type | Description |
|---|---|---|
repoUrl | string | |
accessToken | string | |
prerelease | bool | |
downloader | IFileDownloader |
Properties
| Property | Summary |
|---|---|
RepoUri | The URL of the repository to download releases from. |
Prerelease | If true, the latest upcoming/prerelease release will be downloaded. If false, the latest |
Downloader | The file downloader used to perform HTTP requests. |
AccessToken | The GitLab access token to use with the request to download releases. |
Authorization | The Bearer or other type of Authorization header used to authenticate against the Api. |
RepoUri
public virtual Uri RepoUri { get; }
The URL of the repository to download releases from.
Prerelease
public virtual bool Prerelease { get; }
If true, the latest upcoming/prerelease release will be downloaded. If false, the latest stable release will be downloaded.
Downloader
public virtual IFileDownloader Downloader { get; }
The file downloader used to perform HTTP requests.
AccessToken
protected virtual string? AccessToken { get; }
The GitLab access token to use with the request to download releases.
Authorization
protected abstract (string Name, string Value)? Authorization { get; }
The Bearer or other type of Authorization header used to authenticate against the Api.
Methods
| Method | Summary |
|---|---|
DownloadReleaseEntry | Download the specified VelopackAsset to the provided local file path. |
GetReleaseFeed | Retrieve the list of available remote releases from the package source. These releases |
GetReleases | Retrieves a list of GithubRelease from the current repository. |
GetAssetUrlFromName | Given a GithubRelease and an asset filename (eg. 'RELEASES') this |
GetRequestHeaders | Constructs a dictionary containing HTTP request headers. |
DownloadReleaseEntry(logger, releaseEntry, localFile, progress, cancelToken)
public virtual Task DownloadReleaseEntry(IVelopackLogger logger, VelopackAsset releaseEntry, string localFile, Action<int> progress, CancellationToken cancelToken)
Download the specified VelopackAsset to the provided local file path.
Parameters
| Name | Type | Description |
|---|---|---|
logger | IVelopackLogger | The logger to use for any diagnostic messages. |
releaseEntry | VelopackAsset | The release to download. |
localFile | string | The path on the local disk to store the file. If this file exists, it will be overwritten. |
progress | Action<int> | This delegate will be executed with values from 0-100 as the download is being processed. |
cancelToken | CancellationToken | A token to use to cancel the request. |
Returns Task
GetReleaseFeed(logger, appId, channel, stagingId, latestLocalRelease)
public virtual Task<VelopackAssetFeed> GetReleaseFeed(IVelopackLogger logger, string? appId, string channel, Guid? stagingId = null, VelopackAsset? latestLocalRelease = null)
Retrieve the list of available remote releases from the package source. These releases
can subsequently be downloaded with DownloadReleaseEntry.
Parameters
| Name | Type | Description |
|---|---|---|
logger | IVelopackLogger | The logger to use for any diagnostic messages. |
appId | string | |
channel | string | Release channel to filter packages by. Can be null, which is the default channel for this operating system. |
stagingId | Guid? | A persistent user-id, used for calculating whether a specific release should be available to this user or not. (eg, for the purposes of rolling out an update to only a small portion of users at a time). |
latestLocalRelease | VelopackAsset | The latest / current local release. If specified, metadata from this package may be provided to the remote server (such as package id, or cpu architecture) to ensure that the correct package is downloaded for this user. |
Returns Task<VelopackAssetFeed> — An array of VelopackAsset objects that are available for download
and are applicable to this user.
GetReleases(includePrereleases)
protected abstract Task<T[]> GetReleases(bool includePrereleases)
Retrieves a list of GithubRelease from the current repository.
Parameters
| Name | Type | Description |
|---|---|---|
includePrereleases | bool |
Returns Task<T[]>
GetAssetUrlFromName(release, assetName)
protected abstract string GetAssetUrlFromName(T release, string assetName)
Given a GithubRelease and an asset filename (eg. 'RELEASES') this
function will return either BrowserDownloadUrl or
Url, depending whether an access token is available
or not. Throws if the specified release has no matching assets.
Parameters
| Name | Type | Description |
|---|---|---|
release | T | |
assetName | string |
Returns string
GetRequestHeaders(accept)
protected virtual Dictionary<string, string> GetRequestHeaders(string accept = "application/json")
Constructs a dictionary containing HTTP request headers.
Parameters
| Name | Type | Description |
|---|---|---|
accept | string | The value for the "Accept" header; defaults to "application/json". |
Returns Dictionary<string, string> — A dictionary of headers including "Accept" and, if available, authorization headers.
Generated from Velopack 1.1.1