Documentation
¶
Overview ¶
Package updates checks whether a newer launcher has been released, and finds its installer so the launcher can download and run it.
Index ¶
Constants ¶
const MaxInstaller = 200 << 20
MaxInstaller is the largest installer accepted.
Variables ¶
var Hosts = []string{"api.github.com", "github.com", "objects.githubusercontent.com", "release-assets.githubusercontent.com"}
Hosts are where releases and their files are fetched from: the API, then release downloads, which redirect to GitHub's file hosts.
var LatestURL = "https://api.github.com/repos/diablo2org/launcher/releases/latest"
LatestURL is the GitHub API for the newest non-prerelease release.
Functions ¶
func Apply ¶ added in v0.3.3
Apply puts the downloaded AppImage in place of the running one and starts it once this one has quit (the caller quits).
func CanApply ¶ added in v0.3.3
func CanApply() bool
CanApply reports whether the launcher can replace its AppImage: run from one, in a folder this user can write to. Installed packages (.deb, .rpm) update with the system's package manager instead.
func Download ¶
func Download(ctx context.Context, c *fetch.Client, inst *Installer, dir string, progress fetch.Progress) (string, error)
Download fetches an installer into dir, checking its size and SHA-256, and returns its path. progress may be nil.
The hash comes from the same release, so this catches a corrupted or swapped download, not a compromised release. Once installers are signed, their signature should be checked here too.
Types ¶
type Installer ¶
type Installer struct {
Name string `json:"name"`
URL string `json:"-"`
Size int64 `json:"size"`
SHA256 string `json:"-"`
}
Installer is a release's installer, with what it must match once downloaded.
type Release ¶
type Release struct {
Version string `json:"version"`
// URL is the release page.
URL string `json:"url"`
// Installer is what this machine updates itself from, with a known
// hash: the installer on Windows, the .dmg on macOS and the AppImage on
// Linux where the running launcher can replace itself (Apply). Nil when
// there's none; then the player gets Download or the release page.
Installer *Installer `json:"installer"`
// Download is the package for this system that the player downloads
// and installs themselves, where the launcher doesn't update itself
// yet: the .dmg on macOS, the AppImage on Linux. "" if there's none.
Download string `json:"download"`
}
Release is a newer launcher release.