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 ¶
const ( // Timeout bounds one download stage, including extraction. Timeout = 30 * time.Minute )
Variables ¶
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") )
var DefaultClient = &http.Client{Timeout: Timeout, CheckRedirect: CheckRedirect}
DefaultClient downloads with the default transport and CheckRedirect.
Functions ¶
func CheckRedirect ¶
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.