fetch

package
v0.0.0-...-f1015e0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 21 Imported by: ? 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 fetch runs the download stages of game definitions (cartridge v1, SPEC §3.2): the file is streamed into the data directory, its checksum is verified and it is extracted into the destination. All file operations go through os.Root, so that symlinks in the data directory or in the archive can never lead outside of it.

ipsd runs it on the host, the cartridge runner runs it inside standalone containers.

Index

Constants

View Source
const (
	// Timeout bounds one download stage, including extraction.
	Timeout = 30 * time.Minute
)

Variables

View Source
var (
	// ErrTooLarge is returned when the download or the extracted files exceed the limit.
	ErrTooLarge = errors.New("the download exceeds the free disk space of the game server")
	// ErrUnsafeEntry is returned for archive entries that escape the destination.
	ErrUnsafeEntry = errors.New("archive entry escapes the destination")
)

DefaultClient downloads with the default transport and CheckRedirect.

Functions

func CheckRedirect

func CheckRedirect(req *http.Request, via []*http.Request) error

CheckRedirect follows up to 10 redirects (release assets are served from CDNs), but only to https URLs. Clients passed to Download should use it.

func Download

func Download(ctx context.Context, client *http.Client, root *os.Root, stage cartridge.DownloadStage, limit int64) error

Download runs a download stage inside root. The download and the extracted files together may use at most limit bytes.

func File

func File(ctx context.Context, client *http.Client, root *os.Root, url string, checksum string, dest string, limit int64) error

File downloads one file to dest (relative to root): https only, verified against checksum ("sha256:<hex>" or "sha1:<hex>"), at most limit bytes. The file replaces dest atomically.

Types

This section is empty.

Jump to

Keyboard shortcuts

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