dataset

package
v0.7.87 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dataset finds, downloads, verifies and caches the published dataset for a game build.

Releases are GitHub releases of the data repo named `dataset-<build>`, each with a `manifest-<build>.json` and a `wowc-dataset-<build>.tar.zst` asset (see the data repo's docs/releases.md). A dataset is cached at `<root>/<build>`; the cache only ever holds directories whose every file matched the manifest's sha256 when they were put there.

Index

Constants

View Source
const (
	DefaultReleasesURL = "https://github.com/WoW-Companion/data/releases"
	DefaultAPIURL      = "https://api.github.com/repos/WoW-Companion/data/releases"
)

Variables

View Source
var ErrNoDataset = errors.New("no dataset available")

ErrNoDataset means no cached dataset satisfies the request and none could be downloaded.

Functions

func DefaultRoot

func DefaultRoot() (string, error)

DefaultRoot is the per-user cache: %LOCALAPPDATA%\wowc\dataset on Windows, the XDG cache ($XDG_CACHE_HOME or ~/.cache) on Linux and ~/Library/Caches on macOS.

func Matches

func Matches(gameBuild, clientVersion, clientBuild string) bool

Matches reports whether a dataset's game build is the capture's client: the full "<version>.<build>" or a dotted build ending in the client's build number.

func Same added in v0.7.18

func Same(a, b Manifest) bool

Same reports whether two manifests describe the same published dataset: equal revisions, or, when either lacks one, the same table sha256 set.

Types

type Manifest

type Manifest struct {
	DatasetVersion string `json:"dataset_version"`
	GameBuild      string `json:"game_build"`
	Created        string `json:"created"`
	Revision       string `json:"revision"` // bumped when the data repo republishes the same build
	Tables         []struct {
		Path   string `json:"path"`
		SHA256 string `json:"sha256"`
	} `json:"tables"`
}

Manifest is the part of manifest.json the loader checks.

func ParseManifest

func ParseManifest(data []byte) (Manifest, error)

ParseManifest decodes and checks manifest.json bytes: a game build and tables with safe paths and sha256 sums.

func VerifyDir

func VerifyDir(dir string) (Manifest, error)

VerifyDir re-hashes every file the manifest in dir lists and returns the manifest.

type Result

type Result struct {
	Dir        string
	Build      string
	Downloaded bool  // fetched by this call
	Offline    error // set when the network failed and the cache was used instead
}

Result is a usable dataset directory.

type Store

type Store struct {
	Root        string       // cache root; each dataset is Root/<build>
	ReleasesURL string       // download base, default DefaultReleasesURL
	APIURL      string       // releases API, default DefaultAPIURL
	HTTP        *http.Client // default http.DefaultClient
}

Store downloads into and reads from one cache root.

func (Store) Cached

func (s Store) Cached() (good []string, bad map[string]error)

Cached lists the full builds in the cache whose directories verify, newest first. Directories that fail verification are returned in bad with the reason.

func (Store) CachedManifest added in v0.7.18

func (s Store) CachedManifest(build string) (Manifest, error)

CachedManifest reads the manifest of the cached dataset for a full build.

func (Store) Dir

func (s Store) Dir(build string) string

Dir is where the dataset for a full build lives.

func (Store) Ensure

func (s Store) Ensure(ctx context.Context, want string, update bool) (Result, error)

Ensure returns a verified dataset for want, a client build (a full "1.60.1.71037" or just the number "71037"), downloading it when the cache lacks it. An empty want means the newest: the newest cached dataset when update is false, else the newest release. When the network fails and the cache has a match, the cache is used and Result.Offline says why.

func (Store) Refresh added in v0.7.18

func (s Store) Refresh(ctx context.Context, want string) (build string, updated bool, err error)

Refresh checks the published manifest for a cached build and, when it differs from the cached one (a republish of the same build), downloads and verifies the new archive and replaces the cache directory by a rename. want is a client build as for Ensure; "" means the newest release. It returns the full build checked and whether the cache was replaced. A build that is not cached is left to Ensure; on any error the cache is untouched.

Jump to

Keyboard shortcuts

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