pkgindex

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pkgindex maintains the package index of decision 0018 for the format handlers: which package and version each file belongs to. The item tree stays the source of truth; the index is derived from it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Link(ctx context.Context, st store.Store, v Version, itemID int64, at time.Time) error

Link records that the item with itemID is a file of v, creating the package and version when they are new.

func Prune

func Prune(ctx context.Context, st store.Store, versions []types.PackageVersion) error

Prune runs after items were deleted, which removes their file links with them: each of versions left with no files is deleted, and with it a package left with no versions.

func Reconcile

func Reconcile(ctx context.Context, st store.Store, c repo.Config, want []Indexed) error

Reconcile brings the index of repository c in line with want, a format's reading of c's whole tree, which stays the source of truth (decision 0018): packages and versions want lacks go, and every version want lists is Synced, in name order so the index changes the same way on every store. What want keeps keeps its download statistics and its package's date, so on an index the format's hooks kept right Reconcile changes nothing. Call it inside a transaction.

func RecordDownload

func RecordDownload(ctx context.Context, st store.Store, itemID int64, at time.Time) error

RecordDownload records a download of the item with itemID as its version's last download, when the item belongs to a version, as the item records its own (decision 0018).

func Stored

func Stored(c repo.Config) aql.RepoRef

Stored is where c's package index finds its files: a remote repository's cache, which alone holds a remote's items (decision 0018 indexes items cached from a remote), or the repository's own items. A format's hooks and its reindex both read here and only here, so a reindex rebuilds what the hooks kept.

func Sync

Sync makes version v of package p what the tree says: created when absent, dated and described as v, and linked to exactly v.Files. A version linking anything else is recreated with its dates, download statistics and metadata, as the store cannot unlink one file.

func VersionOf

func VersionOf(
	ctx context.Context,
	st store.Store,
	itemID int64,
) (types.PackageVersion, bool, error)

VersionOf returns the version the item with itemID belongs to; ok is false when it belongs to none.

Types

type Indexed

type Indexed struct {
	Name string
	// Created dates the package when Reconcile creates it. A package already
	// indexed keeps its date, which its first push set.
	Created  time.Time
	Versions []IndexedVersion
}

Indexed is a package as its format reads it from the item tree: what the index must hold for it.

type IndexedVersion

type IndexedVersion struct {
	Version  string
	Created  time.Time
	Metadata []byte
	// Files are the IDs of the version's items.
	Files []int64
}

IndexedVersion is one version of an Indexed package.

type Version

type Version struct {
	RepoKey     string
	PackageType repo.PackageType
	Package     string
	Version     string
}

Version names one version of a package in a repository.

Jump to

Keyboard shortcuts

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