filerepo

package
v0.0.0-...-90deddd Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package filerepo implements a filesystem-backed repository. It stores objects in a directory on disk; the objects are named by the string representation of their digest, i.e., of the form sha256:d60e67ce9....

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository struct {
	// The root directory for this repository. This directory contains
	// all objects.
	Root string

	Log *log.Logger

	// RepoURL may be set to a URL that represents this repository.
	RepoURL *url.URL
	// contains filtered or unexported fields
}

Repository implements a filesystem-backed Repository.

func (*Repository) Collect

func (r *Repository) Collect(ctx context.Context, live liveset.Liveset) error

Collect removes any objects in the repository that are not also in the live set.

func (*Repository) CollectWithThreshold

func (r *Repository) CollectWithThreshold(ctx context.Context, live liveset.Liveset, dead liveset.Liveset, threshold time.Time, dryRun bool) error

CollectWithThreshold removes from this repository any objects not in the Liveset and whose creation times are not more recent than the threshold time.

func (*Repository) Contains

func (r *Repository) Contains(id digest.Digest) (bool, error)

Contains tells whether the repository has an object with a digest.

func (*Repository) Get

Get retrieves the object named by a digest.

func (*Repository) Install

func (r *Repository) Install(file string) (reflow.File, error)

Install links the given file into the repository, named by digest.

func (*Repository) InstallDigest

func (r *Repository) InstallDigest(d digest.Digest, file string) error

InstallDigest installs a file at the given digest. The caller guarantees that the file's bytes have the digest d.

func (*Repository) Materialize

func (r *Repository) Materialize(root string, binds map[string]digest.Digest) error

Materialize takes a mapping of path-to-object, and hardlinks the corresponding objects from the repository into the given root.

func (*Repository) Path

func (r *Repository) Path(id digest.Digest) (dir, path string)

Path returns the filesystem directory and full path of the object with a given digest.

func (*Repository) Put

func (r *Repository) Put(ctx context.Context, body io.Reader) (digest.Digest, error)

Put installs an object into the repository. Its digest identity is returned.

func (*Repository) ReadFrom

func (r *Repository) ReadFrom(ctx context.Context, id digest.Digest, u *url.URL) error

ReadFrom installs an object directly from a foreign repository. If the foreign repository supports supports GetFile, it is used to download directly.

GetFile(ctx context.Context, id digest.Digest, w io.WriterAt) (int64, error)

This is used by implementations like S3, which can download multiple chunks at once, and requires an io.WriterAt so that chunks needn't be buffered in memory until the download is contiguous.

ReadFrom singleflights concurrent downloads from the same key regardless of repository origin.

func (*Repository) Remove

func (r *Repository) Remove(id digest.Digest) error

Remove removes an object from the repository.

func (*Repository) Scan

func (r *Repository) Scan(ctx context.Context, handler func(digest.Digest) error) error

Scan invokes handler for each object in the repository.

func (*Repository) Stat

func (r *Repository) Stat(ctx context.Context, id digest.Digest) (reflow.File, error)

Stat retrieves metadata for files stored in the repository.

func (*Repository) TempFile

func (r *Repository) TempFile(prefix string) (*os.File, error)

TempFile creates and returns a new temporary file adjacent to the repository. Files created by TempFile can be efficiently ingested by Repository.Install. The caller is responsible for cleaning up temporary files.

func (*Repository) URL

func (r *Repository) URL() *url.URL

URL returns the url of this repository.

func (*Repository) Vacuum

func (r *Repository) Vacuum(ctx context.Context, repo *Repository) error

Vacuum moves all objects from the given repository to this one.

func (*Repository) WriteTo

func (r *Repository) WriteTo(ctx context.Context, id digest.Digest, u *url.URL) error

WriteTo writes an object directly to a foreign repository. If the foreign repository supports the PutFile method, it is used.

PutFile(context.Context, reflow.File, io.Reader) error

PutFile is useful for implementations like S3 which can upload multiple chunks at a time, and requires direct reader (and, dynamically, io.Seeker) access.

WriteTo singleflights requests of the same ID and url.

Jump to

Keyboard shortcuts

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