Documentation
¶
Index ¶
- func CacheDir() (string, error)
- func CacheUsage() (dir string, debs int, bytes int64, err error)
- func ClearCache() (removed int, err error)
- func HumanBytes(n int64) string
- func PruneExpired() (removed int, err error)
- func Resolve(ctx context.Context, ids, sources []string, noRecurse bool, cacheDir string, ...) ([]string, error)
- func ResolveVersion(ctx context.Context, ids, sources []string, noRecurse bool, cacheDir string, ...) ([]string, error)
- type Entry
- type PkgVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.