updater

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package updater queries the ingest server for the latest published version of a client app and reports whether an update is available or the running version has been deprecated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupLeftovers

func CleanupLeftovers(target string)

CleanupLeftovers removes `.old` and the staged sibling left next to target by a swap whose best-effort cleanup did not finish. It is a no-op when target is absent, so it can never delete the last surviving copy of the app. Best-effort.

func CurrentPlatform

func CurrentPlatform() (string, string)

CurrentPlatform returns the (platform, arch) for the running binary.

func Download

func Download(ctx context.Context, url, wantSHA string, wantSize int64, dest string, progress func(done, total int64)) error

Download streams the artifact at url into dest, computing its SHA256 as it goes and failing if the hash, byte count, or size cap is violated. progress (if non-nil) is called after each chunk with (bytesWritten, wantSize).

On any error dest may contain a partial file; callers download into a temp dir and discard it on failure.

func InstallTarget

func InstallTarget() (string, error)

InstallTarget resolves the path that the swap will replace: the .app bundle on macOS, or the .exe on Windows/Linux. Returns an error if the running binary is not laid out like an installed app (e.g. `wails dev`).

func RunApplyUpdate

func RunApplyUpdate(pid int, staged, target string) error

RunApplyUpdate waits for the parent to exit, swaps the staged payload into place, and relaunches. If the parent is still alive after the timeout it aborts rather than risk swapping a locked file.

func RunApplyUpdateFromArgs

func RunApplyUpdateFromArgs(args []string) error

RunApplyUpdateFromArgs parses the helper flags and runs the swap. Invoked from main.go when the binary is started with `--apply-update`.

func SpawnHelper

func SpawnHelper(staged, target string) error

SpawnHelper prepares a runnable copy of this app in a temp location and starts it detached with `--apply-update`, passing this process's pid so the helper can wait for us to exit before swapping. Returns once the helper has started.

func Stage

func Stage(artifactPath, targetDir string) (string, error)

Stage extracts the update payload from artifactPath into targetDir, next to where the swap will place it (same directory -> same volume -> rename is atomic-ish). Returns the staged path. Any pre-existing staged path is removed first.

func TargetWritable

func TargetWritable(target string) bool

TargetWritable reports whether the directory containing target can be written to — a precondition for the in-place swap. Advisory only: a real failure still surfaces later as an error and falls back to the browser path.

Types

type Status

type Status struct {
	OK               bool // True only when Check successfully reached the server and decoded a 2xx response.
	UpdateAvailable  bool
	MandatoryUpdate  bool
	IsSupported      bool
	Latest           string
	ReleasedAt       time.Time
	ReleaseNotesHTML string
	DownloadURL      string
	SHA256           string
	SizeBytes        int64
}

Status is the result of a single version check. Zero value means "no update, not in an unsupported state" — safe for the UI to render as "carry on, no banner".

func Check

func Check(ctx context.Context, ingestBase, appID, currentVersion string) (Status, error)

Check queries ingestBase/api/v1/apps/{appID}/latest using the running binary's platform/arch. A zero Status + error is returned on network failure or non-2xx responses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL