fetch

package
v0.0.0-...-f14773f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() (string, error)

CacheDir returns the persistent fetch cache directory (os.UserCacheDir()/xkvm/fetch, ~/.cache/xkvm/fetch on systems without a user cache dir). Fetched dependency .debs live here so a later run that needs the same package reuses the download instead of hitting the network, and stale entries are pruned by the 7-day TTL on every Resolve.

func CacheUsage

func CacheUsage() (dir string, debs int, bytes int64, err error)

CacheUsage reports the persistent cache directory and what's in it: the number of cached .debs and their total size. Used by `xkvm cache` and the TUI cache menu so users can see what the smart dependency solver has downloaded without digging through the filesystem.

func ClearCache

func ClearCache() (removed int, err error)

ClearCache removes EVERY cached .deb, regardless of age, and returns how many were removed. The explicit "forget everything" — distinct from PruneExpired's 7-day TTL sweep.

func HumanBytes

func HumanBytes(n int64) string

HumanBytes renders a byte count readably (B / KB / MB / GB / TB, one decimal), Shared by `xkvm cache` and the TUI cache menu. Units clamp at TB: anything larger still formats (no panic on absurd input).

func PruneExpired

func PruneExpired() (removed int, err error)

PruneExpired removes cached .debs older than the 7-day TTL and returns how many were dropped. Missing cache directory is not an error — there's nothing to prune. Used by `xkvm cache --clear` and the TUI cache menu.

func Resolve

func Resolve(ctx context.Context, ids, sources []string, noRecurse bool, cacheDir string, client *http.Client) ([]string, error)

Resolve fetches the given package ids — plus their Depends: closures unless noRecurse — as .debs into cacheDir, and returns the local paths in resolution order, deduplicated by package id. sources (from --apt-source) are searched before the Canister index; when an id isn't in any listed source, Canister resolves which repo hosts it.

func ResolveVersion

func ResolveVersion(ctx context.Context, ids, sources []string, noRecurse bool, cacheDir string, client *http.Client, pinned map[string]string) ([]string, error)

ResolveVersion is Resolve with optional Canister version pins: when pinned[id] is non-empty that exact version is downloaded for id instead of the default latest. Dependencies are never pinned — only the ids named in the map. Callers without pins can just use Resolve.

Types

type Entry

type Entry struct {
	Package      string
	Version      string
	Depends      string
	Filename     string
	SHA256       string
	Architecture string
}

Entry is one stanza from a MobileAPT Packages index.

type PkgVersion

type PkgVersion struct {
	Version string // the exact version string (also the cache-key version)
	RepoID  string // hosting repository (shown in pickers, useful for logs)
	Latest  bool   // is this the version Resolve would download by default
}

PkgVersion is one available free version of a Canister-hosted package.

func Versions

func Versions(ctx context.Context, id string, client *http.Client) ([]PkgVersion, error)

Versions lists the free, visible versions of a Canister package — latest first, deduplicated. It powers the TUI version picker; the CLI equivalent is the researcher-facing pin passed to ResolveVersion.

Jump to

Keyboard shortcuts

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