Documentation
¶
Overview ¶
Package updater keeps an app up to date the way its platform does. On direct macOS and Windows builds, Sparkle and WinSparkle, which nsgo build bundles when nsgo.yaml configures updates, read the app's appcast on their own schedule, download a newer release, verify its EdDSA signature, install it and restart the app. Linux and direct Android builds read the same appcast and install its verified package after confirmation. Apple App Store builds offer their store page; Google Play handles a manual check with its native update flow.
Index ¶
- Constants
- func Check(cx *core.Scope)
- func CheckDaily(cx *core.Scope)
- func CheckInBackground(cx *core.Scope)
- func Download(ctx context.Context, update core.UpdateCheck, dir string, ...) (string, error)
- func Install(cx *core.Scope, path string, done func(error))
- func SetAutomaticChecks(cx *core.Scope, on bool)
- func SetAutomaticDownloads(cx *core.Scope, on bool)
- type Capability
- type DownloadProgress
- type Managed
- type Phase
- type State
Constants ¶
const ( // PhaseIdle says no update is downloading or installing. PhaseIdle = core.UpdateIdle // PhaseDownloading says an update package is streaming to disk. PhaseDownloading = core.UpdateDownloading // PhaseInstalling says the verified package is being installed. PhaseInstalling = core.UpdateInstalling )
const ( ManagedSelf = core.UpdaterSelf ManagedPage = core.UpdaterPage ManagedDevelopment = core.UpdaterDevelopment ManagedChannel = core.UpdaterChannel ManagedStore = core.UpdaterStore )
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check checks for a newer version now, as a Check for Updates… item does, and shows what it finds: on direct macOS and Windows in Sparkle's and WinSparkle's windows, on Linux and direct Android an alert that installs the signed package after confirmation, on Google Play its native update flow, elsewhere an alert that offers to open the newer version's page, says the app is up to date, or says the check failed.
func CheckDaily ¶
CheckDaily checks in the background, as CheckInBackground does, unless it has within the last day, so a newer version is offered once a day rather than at every start. Sparkle and WinSparkle keep such a schedule of their own; on Linux, direct Android and Apple App Store builds nsgo.Run calls CheckDaily as the app starts and as the user comes back to it when nsgo.yaml's updates.automatic is on. A check that failed, as one offline does, is tried again an hour later.
func CheckInBackground ¶
CheckInBackground checks without showing anything unless it finds a newer version, as the platforms' scheduled checks do.
func Download ¶
func Download(ctx context.Context, update core.UpdateCheck, dir string, progress func(DownloadProgress)) (string, error)
Download streams an update's signed package directly to a temporary file in dir. It verifies size, SHA-256 and Ed25519 signature from the streamed file before making it visible, removing partial or invalid files on error.
func Install ¶
Install hands a verified update package to the platform's installer. Linux reports when its package manager exits. Android reports when its system installer opens. The callback runs on the app's graph goroutine.
func SetAutomaticChecks ¶
SetAutomaticChecks persists the user's choice. Native updaters own their preferences; the daily scheduler on Linux, Android and iOS uses its own partition.
func SetAutomaticDownloads ¶
SetAutomaticDownloads changes Sparkle's persisted choice on macOS. It is a no-op on platforms with no automatic-download setting.
Types ¶
type Capability ¶
Capability describes how this copy updates. Store names its installer when ManagedStore.
func CapabilityOf ¶
func CapabilityOf(cx *core.Scope) Capability
CapabilityOf reports how this copy updates, synchronously and without network I/O.
type DownloadProgress ¶
type DownloadProgress struct {
Loaded, Total int64
}
DownloadProgress reports bytes written while an update is downloaded.
type Managed ¶
type Managed = core.UpdaterManaged
Managed identifies who updates an installed copy, without checking a feed.
type Phase ¶
type Phase = core.UpdatePhase
Phase is what an in-app update is doing on Linux and Android.
type State ¶
type State struct {
Capability Capability
AutomaticChecks, AutomaticDownloads bool
Available, Notes string
LastCheck time.Time
Phase Phase
Loaded, Total int64
}
State is the updater's latest knowledge. Reading Status in a binding tracks changes. AutomaticDownloads is supported only by Sparkle on macOS. Phase, Loaded and Total follow an in-app update that downloads and installs on Linux and Android.