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 ¶
- func Link(ctx context.Context, st store.Store, v Version, itemID int64, at time.Time) error
- func Prune(ctx context.Context, st store.Store, versions []types.PackageVersion) error
- func Reconcile(ctx context.Context, st store.Store, c repo.Config, want []Indexed) error
- func RecordDownload(ctx context.Context, st store.Store, itemID int64, at time.Time) error
- func Stored(c repo.Config) aql.RepoRef
- func Sync(ctx context.Context, st store.Store, p types.Package, v IndexedVersion) (types.PackageVersion, error)
- func VersionOf(ctx context.Context, st store.Store, itemID int64) (types.PackageVersion, bool, error)
- type Indexed
- type IndexedVersion
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Link ¶
Link records that the item with itemID is a file of v, creating the package and version when they are new.
func Prune ¶
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 ¶
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 ¶
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 ¶
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 ¶
func Sync( ctx context.Context, st store.Store, p types.Package, v IndexedVersion, ) (types.PackageVersion, error)
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.
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.