update

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(bytes int64) string

FormatSize formats bytes as human-readable string.

func GetCacheDir

func GetCacheDir() string

GetCacheDir returns the roborev cache directory

func PerformUpdate

func PerformUpdate(info *UpdateInfo, progressFn func(downloaded, total int64)) error

PerformUpdate downloads and installs the update.

func RestartDaemon

func RestartDaemon() error

RestartDaemon stops and starts the daemon

Types

type Asset

type Asset struct {
	Name               string `json:"name"`
	Size               int64  `json:"size"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

Asset represents a release asset

type Deps added in v0.49.0

type Deps struct {
	Client     *http.Client
	Now        func() time.Time
	Version    string
	GOOS       string
	GOARCH     string
	CacheDir   func() string
	Executable func() (string, error)
	MkdirTemp  func(dir, pattern string) (string, error)
}

Deps holds environment and process dependencies for updater operations.

type Release

type Release struct {
	TagName string  `json:"tag_name"`
	Body    string  `json:"body"`
	Assets  []Asset `json:"assets"`
}

Release represents a GitHub release

type Reporter added in v0.49.0

type Reporter interface {
	Stepf(format string, args ...any)
	Progress(downloaded, total int64)
}

Reporter handles user-facing update progress.

type UpdateInfo

type UpdateInfo struct {
	CurrentVersion string
	LatestVersion  string
	DownloadURL    string
	AssetName      string
	Size           int64
	Checksum       string // SHA256 if available
	IsDevBuild     bool   // True if running a dev build (hash version)
}

UpdateInfo contains information about an available update

func CheckForUpdate

func CheckForUpdate(forceCheck bool) (*UpdateInfo, error)

CheckForUpdate checks if a newer version is available. Uses a 1-hour cache to avoid hitting GitHub API too often.

type Updater added in v0.49.0

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

Updater coordinates release checks and installs using injected dependencies.

func NewUpdater added in v0.49.0

func NewUpdater(deps Deps) *Updater

NewUpdater returns an updater with defaults filled for any missing dependencies.

func (*Updater) CheckForUpdate added in v0.49.0

func (u *Updater) CheckForUpdate(forceCheck bool) (*UpdateInfo, error)

CheckForUpdate checks if a newer version is available.

func (*Updater) PerformUpdate added in v0.49.0

func (u *Updater) PerformUpdate(info *UpdateInfo, reporter Reporter) error

PerformUpdate downloads and installs the update.

Jump to

Keyboard shortcuts

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