Saltar al contenido principal

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

ConstructorSummary
GitBaseBase constructor.

GitBase(repoUrl, accessToken, prerelease, downloader)

protected GitBase(string repoUrl, string? accessToken, bool prerelease, IFileDownloader? downloader = null)

Base constructor.

Parameters

NameTypeDescription
repoUrlstring
accessTokenstring
prereleasebool
downloaderIFileDownloader

Properties

PropertySummary
RepoUriThe URL of the repository to download releases from.
PrereleaseIf true, the latest upcoming/prerelease release will be downloaded. If false, the latest
DownloaderThe file downloader used to perform HTTP requests.
AccessTokenThe GitLab access token to use with the request to download releases.
AuthorizationThe 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

MethodSummary
DownloadReleaseEntryDownload the specified VelopackAsset to the provided local file path.
GetReleaseFeedRetrieve the list of available remote releases from the package source. These releases
GetReleasesRetrieves a list of GithubRelease from the current repository.
GetAssetUrlFromNameGiven a GithubRelease and an asset filename (eg. 'RELEASES') this
GetRequestHeadersConstructs 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

NameTypeDescription
loggerIVelopackLoggerThe logger to use for any diagnostic messages.
releaseEntryVelopackAssetThe release to download.
localFilestringThe path on the local disk to store the file. If this file exists,
it will be overwritten.
progressAction<int>This delegate will be executed with values from 0-100 as the
download is being processed.
cancelTokenCancellationTokenA 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

NameTypeDescription
loggerIVelopackLoggerThe logger to use for any diagnostic messages.
appIdstring
channelstringRelease channel to filter packages by. Can be null, which is the
default channel for this operating system.
stagingIdGuid?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).
latestLocalReleaseVelopackAssetThe 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

NameTypeDescription
includePrereleasesbool

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

NameTypeDescription
releaseT
assetNamestring

Returns string

GetRequestHeaders(accept)

protected virtual Dictionary<string, string> GetRequestHeaders(string accept = "application/json")

Constructs a dictionary containing HTTP request headers.

Parameters

NameTypeDescription
acceptstringThe 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