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 ¶
- func CleanupLeftovers(target string)
- func CurrentPlatform() (string, string)
- func Download(ctx context.Context, url, wantSHA string, wantSize int64, dest string, ...) error
- func InstallTarget() (string, error)
- func RunApplyUpdate(pid int, staged, target string) error
- func RunApplyUpdateFromArgs(args []string) error
- func SpawnHelper(staged, target string) error
- func Stage(artifactPath, targetDir string) (string, error)
- func TargetWritable(target string) bool
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupLeftovers ¶ added in v0.1.12
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 ¶
CurrentPlatform returns the (platform, arch) for the running binary.
func Download ¶ added in v0.1.12
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 ¶ added in v0.1.12
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 ¶ added in v0.1.12
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 ¶ added in v0.1.12
RunApplyUpdateFromArgs parses the helper flags and runs the swap. Invoked from main.go when the binary is started with `--apply-update`.
func SpawnHelper ¶ added in v0.1.12
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 ¶ added in v0.1.12
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 ¶ added in v0.1.12
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".