ybdata

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package ybdata locates directories the user has designated or conventionally uses for storing different types of data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound added in v0.4.3

func IsNotFound(e error) bool

IsNotFound reports whether e indicates an HTTP 404 Not Found or 410 Gone response.

Types

type Dirs

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

Dirs is the result of locating directories.

func DirsFromEnv

func DirsFromEnv() (*Dirs, error)

DirsFromEnv finds data directories based on environment variables.

func NewDirs

func NewDirs(root string) *Dirs

NewDirs returns a set of directories that is enclosed within a root directory. This is useful for isolating test data.

func (*Dirs) BuildHome added in v0.4.3

func (dirs *Dirs) BuildHome(packageDir, target string, desc *biome.Descriptor) (string, error)

BuildHome finds or creates a directory to store cached data for a target.

func (*Dirs) BuildHomeRoot added in v0.6.0

func (dirs *Dirs) BuildHomeRoot(packageDir string) string

BuildHomeRoot finds the directory that contains the targets' home directories.

TODO(ch2755): This should get moved to a directory physically in the package directory.

func (*Dirs) Downloads

func (dirs *Dirs) Downloads() string

Downloads returns the top-level directory to store downloaded files. This directory may not exist yet.

func (*Dirs) FindBuildHome added in v0.6.0

func (dirs *Dirs) FindBuildHome(packageDir, target string, desc *biome.Descriptor) string

FindBuildHome finds a directory to store cached data for a target.

type Downloader added in v0.6.0

type Downloader struct {
	// Client is the HTTP client to use to fetch URLs.
	// This can only be changed before the first call to Download.
	Client *http.Client
	// contains filtered or unexported fields
}

Downloader manages a download cache.

func NewDownloader added in v0.6.0

func NewDownloader(dir string) *Downloader

NewDownloader returns a Downloader that maintains a cache in the given directory. The Downloader will create the directory if it does not exist.

func (*Downloader) Download added in v0.6.0

func (d *Downloader) Download(ctx context.Context, url string) (_ *os.File, err error)

Download downloads a URL to the local filesystem and returns a handle to the file. If the URL could not be found on the server, then IsNotFound(err) will return true.

Jump to

Keyboard shortcuts

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