cache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package cache manages downloaded files and their metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloadOptions

type DownloadOptions struct {
	LicenseKey string
	DownloadID string // e.g., "xenforo", "xfmg"
	Version    string
	URL        string

	Filename       string // overrides Content-Disposition
	SkipCacheCheck bool
	// contains filtered or unexported fields
}

DownloadOptions specifies download parameters.

type DownloadResult

type DownloadResult struct {
	Entry     *Entry
	WasCached bool
}

DownloadResult contains information about a completed download.

type Entry

type Entry struct {
	LicenseKey string
	Metadata   entryMetadata
	FilePath   string
}

Entry represents a cached download file.

func FindValid added in v0.5.0

func FindValid(m entryVerifier, licenseKey string, downloadID, version string) (*Entry, error)

FindValid returns the cached entry whose file exists and passes verification, or nil if there is none. Only a failure to look up the entry is returned as an error; a corrupt or missing file counts as no entry.

type Manager

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

Manager manages cache storage on disk.

func NewManager

func NewManager() (*Manager, error)

NewManager creates a new cache manager.

func (*Manager) Download

func (m *Manager) Download(ctx context.Context, opts DownloadOptions, authToken string, progress ProgressCallback) (*DownloadResult, error)

Download downloads and caches a file, optionally using an authentication token.

func (*Manager) GetEntry

func (m *Manager) GetEntry(licenseKey string, downloadID, version string) (*Entry, error)

GetEntry retrieves a cache entry by license, download ID, and version.

func (*Manager) List

func (m *Manager) List() ([]*Entry, error)

List returns all cached entries.

func (*Manager) ListForLicense

func (m *Manager) ListForLicense(licenseKey string) ([]*Entry, error)

ListForLicense returns all cached entries for a specific license.

func (*Manager) PurgeAll

func (m *Manager) PurgeAll() error

PurgeAll removes all cached files.

func (*Manager) PurgeLicense

func (m *Manager) PurgeLicense(licenseKey string) error

PurgeLicense removes all cached files for a specific license.

func (*Manager) Verify

func (m *Manager) Verify(entry *Entry) (bool, error)

Verify checks if a cached file's checksum is valid.

type ProgressCallback

type ProgressCallback func(current, total int64)

ProgressCallback reports download progress; total is -1 if unknown.

Jump to

Keyboard shortcuts

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