update

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package update provides functionality for checking and managing OpenPass updates.

Index

Constants

View Source
const (
	// DefaultCacheTTL is the default time-to-live for cached update check results.
	DefaultCacheTTL = 24 * time.Hour
)
View Source
const DefaultLatestReleaseURL = "https://api.github.com/repos/danieljustus/OpenPass/releases/latest"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache manages persistent caching of update check results.

func NewCache

func NewCache() *Cache

NewCache creates a new Cache instance with the default location and TTL.

func NewCacheWithTTL

func NewCacheWithTTL(path string, ttl time.Duration) *Cache

NewCacheWithTTL creates a new Cache instance with a custom path and TTL. If path is empty, the default location (~/.openpass/update-cache.json) is used.

func (*Cache) Invalidate

func (c *Cache) Invalidate() error

Invalidate removes the cache file.

func (*Cache) Load

func (c *Cache) Load() (*CacheEntry, error)

Load reads the cache entry from disk if it exists and is still valid. Returns nil if the cache doesn't exist, is expired, or can't be read.

func (*Cache) Path

func (c *Cache) Path() string

Path returns the cache file path.

func (*Cache) Save

func (c *Cache) Save(entry *CacheEntry) error

Save writes the cache entry to disk.

func (*Cache) TTL

func (c *Cache) TTL() time.Duration

TTL returns the cache time-to-live duration.

type CacheEntry

type CacheEntry struct {
	Timestamp     time.Time `json:"timestamp"`
	LatestVersion string    `json:"latest_version"`
	ReleaseURL    string    `json:"release_url"`
}

CacheEntry represents a cached update check result.

type Checker

type Checker struct {
	HTTPClient       httpDoer
	LatestReleaseURL string
	Cache            *Cache
}

func NewChecker

func NewChecker(client httpDoer) *Checker

func (*Checker) Check

func (c *Checker) Check(ctx context.Context, currentVersion string) (*Result, error)

func (*Checker) CheckWithForce

func (c *Checker) CheckWithForce(ctx context.Context, currentVersion string, force bool) (*Result, error)

type Result

type Result struct {
	CurrentVersion  string
	LatestVersion   string
	ReleaseURL      string
	Checkable       bool
	UpdateAvailable bool
}

Jump to

Keyboard shortcuts

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