updatecheck

package
v0.1.0-alpha.49 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: GPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package updatecheck compares the running build with MagicHandy's latest compatible GitHub release. It only discovers releases; installing one remains an explicit user action through the release page.

Index

Constants

View Source
const (
	// DefaultReleaseAPIURL lists enough releases to select the highest version
	// compatible with the running build's stable or prerelease channel.
	DefaultReleaseAPIURL = "https://api.github.com/repos/MagicHandy/MagicHandy/releases?per_page=100"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker serializes release requests and keeps their ETag-backed result in memory. A browser refresh therefore does not spend another unauthenticated GitHub API request.

func New

func New(options Options) *Checker

New constructs a release checker with conservative network defaults.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context, refresh bool) Status

Check returns a cached result unless refresh is requested or the cache has expired. A failed refresh keeps the last successful result, marked stale.

type Options

type Options struct {
	CurrentVersion string
	Endpoint       string
	HTTPClient     *http.Client
	Clock          func() time.Time
	CacheTTL       time.Duration
}

Options configure a Checker. Endpoint, Clock, and CacheTTL are injectable so tests never contact GitHub.

type Release

type Release struct {
	Version     string    `json:"version"`
	Tag         string    `json:"tag"`
	Name        string    `json:"name,omitempty"`
	URL         string    `json:"url"`
	PublishedAt time.Time `json:"published_at,omitempty"`
}

Release is the small, trusted subset of GitHub release data the UI needs.

type State

type State string

State describes the result without making network failure look like an app failure.

const (
	// StateAvailable means a newer compatible release exists.
	StateAvailable State = "available"
	// StateCurrent means the running version is at least as new as the latest compatible release.
	StateCurrent State = "current"
	// StateDevelopment means the running build has no comparable semantic version.
	StateDevelopment State = "development"
	// StateNoRelease means the repository has no compatible published release.
	StateNoRelease State = "no_release"
	// StateError means the release check could not produce a result.
	StateError State = "error"
)

type Status

type Status struct {
	State          State     `json:"state"`
	CurrentVersion string    `json:"current_version"`
	Latest         *Release  `json:"latest,omitempty"`
	CheckedAt      time.Time `json:"checked_at,omitempty"`
	Stale          bool      `json:"stale,omitempty"`
	Message        string    `json:"message,omitempty"`
}

Status is returned by the local API for both startup and manual checks.

Jump to

Keyboard shortcuts

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