update

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: GPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReleaseNotFound = errors.New("release not found")
	ErrNotNewer        = errors.New("release is not newer than the running version")
	// ErrSwap marks a failure to replace the binary on disk, such as a permission error.
	ErrSwap = errors.New("could not replace the binary")
)

Functions

func Supervise added in v1.31.0

func Supervise(func(msg string))

Supervise does nothing on Unix, where a Restart execs in place.

Types

type Availability added in v1.31.0

type Availability struct {
	SelfUpdate                  bool
	SelfUpdateUnavailableReason string
	Restart                     bool
}

Availability reports which of Self-update and Restart qui offers.

func Decide added in v1.31.0

func Decide(in Inputs) Availability

type Config

type Config struct {
	Repository string
	Version    string
	// BinaryPath is the binary that Install replaces, resolved at startup. Run
	// resolves its own.
	BinaryPath string
}

type Inputs added in v1.31.0

type Inputs struct {
	AppContainer      bool
	DisableSelfUpdate bool
	ReleaseVersion    bool
	DirWritable       bool
	// BinaryPath is the resolved binary that a Restart execs. Decide ignores it.
	BinaryPath string
}

Inputs are the facts that decide Availability. qui measures them once at startup.

func Measure added in v1.31.0

func Measure(log zerolog.Logger, disableSelfUpdate bool, version string) Inputs

Measure reads the Availability inputs from the host and logs each one at DEBUG level.

type Restarter added in v1.31.0

type Restarter struct {
	// Mutex is the one lock over every system action, taken with TryLock by the
	// API and the Tray. A successful action ends in a Restart, so only a failed
	// action unlocks it.
	sync.Mutex
	// contains filtered or unexported fields
}

Restarter carries a Restart request from the API to the serve loop. See docs/adr/0011-restart-replaces-the-process-in-place.md.

func NewRestarter added in v1.31.0

func NewRestarter(binaryPath string) *Restarter

NewRestarter takes the binary path that Measure resolved at startup, before a Self-update can replace the file.

func (*Restarter) Request added in v1.31.0

func (r *Restarter) Request() error

Request checks the binary, then asks the serve loop to restart. On an error qui keeps running: on Unix without a supervisor, a failed exec leaves qui down.

func (*Restarter) Requested added in v1.31.0

func (r *Restarter) Requested() <-chan struct{}

func (*Restarter) Restart added in v1.31.0

func (r *Restarter) Restart(log zerolog.Logger, shutdown func() error)

Restart runs the graceful shutdown, then starts the binary again: on Unix through an exec in place, on Windows through the supervisor. It never returns. A shutdown error, such as the 30-second timeout, does not stop the restart.

type Result added in v1.31.0

type Result struct {
	// Version has no "v" prefix, the same format as GET /api/version.
	Version         string `json:"version"`
	RollbackCommand string `json:"rollbackCommand"`
	BackupError     string `json:"backupError"`
}

Result describes a successful Self-update.

type Service

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

Service periodically checks api.autobrr.com for new qui releases and caches the latest result.

func NewService

func NewService(log zerolog.Logger, enabled bool, currentVersion, userAgent string) *Service

NewService creates a new update Service instance.

func (*Service) CheckUpdateAvailable

func (s *Service) CheckUpdateAvailable(ctx context.Context) (*version.Release, error)

CheckUpdateAvailable performs an update check and returns the new release if one is available.

func (*Service) CheckUpdates

func (s *Service) CheckUpdates(ctx context.Context)

CheckUpdates triggers a refresh of the latest release information if updates are enabled.

func (*Service) GetLatestRelease

func (s *Service) GetLatestRelease(_ context.Context) *version.Release

GetLatestRelease returns the last known release if a newer version has been found.

func (*Service) SetEnabled

func (s *Service) SetEnabled(enabled bool)

SetEnabled toggles whether periodic update checks should run.

func (*Service) Start

func (s *Service) Start(ctx context.Context)

Start launches a background loop that periodically checks for updates while the context is active.

type Updater

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

func NewUpdater

func NewUpdater(config Config) *Updater

func (*Updater) Install added in v1.31.0

func (u *Updater) Install(ctx context.Context, tag string) (Result, error)

Install replaces the binary with the release that has this exact tag. It never falls back to the latest release: the dialog showed this tag, and the user read the notes for it. On an error the binary does not change.

func (*Updater) Run

func (u *Updater) Run(ctx context.Context) error

Run installs the latest release. It serves the qui update CLI command.

Jump to

Keyboard shortcuts

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