export

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: AGPL-3.0 Imports: 28 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 export runs the DB2 → SQLite export pipeline.

Index

Constants

View Source
const (
	SourceLocal = "local"
	SourceCDN   = "cdn"
)

Source values (_meta.source).

View Source
const (
	StateNeverExported = "never_exported"
	StateUpToDate      = "up_to_date"
	StateStale         = "stale"

	ReasonBuildChanged    = "build_changed"
	ReasonHotfixesChanged = "hotfixes_changed"
	ReasonSchemaChanged   = "schema_changed"
	ReasonDefsChanged     = "defs_changed"
	ReasonSourceChanged   = "source_changed"
)

Status states and reasons.

View Source
const CurrentName = "current.sqlite"

CurrentName is the symlink pointing at the latest export.

Variables

View Source
var ErrLocked = errors.New("another export is running")

ErrLocked means another export holds the output directory lock.

Functions

func DefsSHA256

func DefsSHA256(s *defs.Snapshot) (string, error)

DefsSHA256 returns the digest of the snapshot's canonical content.

func FileName

func FileName(version string) string

FileName returns the file name of a local export of version.

func HotfixSHA256

func HotfixSHA256(inst *install.Install) (string, error)

HotfixSHA256 returns the hex SHA-256 of the install's DBCache.bin, or "" when the file does not exist.

func IsFatal

func IsFatal(err error) bool

IsFatal reports whether a writer error means the database can no longer be written (disk full, I/O error, closed database) rather than a problem with one table.

func RemoteFileName

func RemoteFileName(version, source string) string

RemoteFileName returns the file name of an export of version read from source (e.g. wowf-1.60.1.71037-cdn.sqlite).

Types

type Options

type Options struct {
	Dir, OutDir string  // OutDir also holds the optional defs.json.gz override; Dir is unused with Remote
	Remote      *Remote // nil = read the local install in Dir
	// HotfixesPath overrides the DBCache.bin to apply. Empty: the install's
	// DBCache.bin for a local export, no hotfixes for a remote one.
	HotfixesPath string
	ToolVersion  string
	Workers      int // 0 → runtime.NumCPU()
	Now          func() time.Time
	// contains filtered or unexported fields
}

Options configures Run.

type Remote

type Remote struct {
	Source      string // e.g. SourceCDN
	Version     string
	BuildNumber uint32
	BuildKey    string // build config hash
	Locale      string
	// Open opens the storage with the snapshot's key ring. Run closes the
	// returned source when it implements io.Closer.
	Open func(keys db2.KeyRing) (dataset.FileSource, error)
}

Remote is a game build read from somewhere other than a local install. export never opens network storage itself: the caller provides Open.

type StatusReport

type StatusReport struct {
	State            string   `json:"state"`
	Reasons          []string `json:"reasons"`
	InstalledVersion string   `json:"installed_version"`
	ExportedVersion  string   `json:"exported_version"`
	Database         string   `json:"database"`
}

StatusReport describes how the last export compares to the install.

func Status

func Status(inst *install.Install, outDir string) (*StatusReport, error)

Status compares <outDir>/current.sqlite with inst.

type Summary

type Summary struct {
	Version, OutputPath string
	Source              string // SourceLocal or SourceCDN
	Counts              map[dataset.TableStatus]int
	Failed              []TableFailure
	Hotfix              hotfix.Stats
	SkippedRows         int
	MissingKeys         map[uint64]int
	DBCacheStatus       dataset.HotfixStatus
	ClientKeysAdded     int
	Duration            time.Duration
	DefsOrigin          string // defs.OriginEmbedded or defs.OriginLocal
	DefsCommit          string // WoWDBDefs commit of the snapshot
	DefsGeneratedAt     string
}

Summary reports an export.

func Run

func Run(ctx context.Context, opts Options) (*Summary, error)

Run exports every snapshot table. By default it reads the install in opts.Dir, writes <OutDir>/wowf-<version>.sqlite and points current.sqlite at it. With opts.Remote it reads that build instead, writes <OutDir>/wowf-<version>-<source>.sqlite and leaves current.sqlite alone: current always tracks the local install.

type TableFailure

type TableFailure struct {
	Name, Error string
}

TableFailure names a table that failed to export.

type TableStatusRow

type TableStatusRow struct {
	TableName       string
	FDID            uint32
	TableHash       string
	LayoutHash      string
	MatchedBy       string
	Status          string
	Error           string
	BaseRows        int
	HotfixUpserts   int
	HotfixDeletes   int
	HotfixReverts   int
	HotfixErrors    int
	SkippedRows     int
	SkippedSections int
}

TableStatusRow is one _tables row.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes an export database. It is not safe for concurrent use: a single goroutine owns it.

func OpenWriter

func OpenWriter(path string) (*Writer, error)

OpenWriter creates a new database at path, which must not exist.

func (*Writer) Close

func (w *Writer) Close() error

Close closes the database and syncs the file to disk.

func (*Writer) CreateIndexes

func (w *Writer) CreateIndexes(defs []*db2.Definition) error

CreateIndexes creates the reference and relation indexes of defs.

func (*Writer) WriteHotfixLog

func (w *Writer) WriteHotfixLog(table string, logs []hotfix.LogEntry) error

WriteHotfixLog inserts the hotfix log of table in one transaction.

func (*Writer) WriteMeta

func (w *Writer) WriteMeta(meta map[string]string) error

WriteMeta inserts or replaces _meta keys.

func (*Writer) WriteTable

func (w *Writer) WriteTable(t *db2.Table) error

WriteTable creates the data table of t in one transaction (DDL included, so a failure leaves no partial table), inserts its rows in ascending ID order, and records its columns in _columns.

func (*Writer) WriteTableStatus

func (w *Writer) WriteTableStatus(r TableStatusRow) error

WriteTableStatus inserts one _tables row.

Source Files

  • export.go
  • status.go
  • writer.go

Jump to

Keyboard shortcuts

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