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 ¶
- type Repository
- func (r *Repository) Collect(ctx context.Context, live liveset.Liveset) error
- func (r *Repository) CollectWithThreshold(ctx context.Context, live liveset.Liveset, dead liveset.Liveset, ...) error
- func (r *Repository) Contains(id digest.Digest) (bool, error)
- func (r *Repository) Get(ctx context.Context, id digest.Digest) (io.ReadCloser, error)
- func (r *Repository) Install(file string) (reflow.File, error)
- func (r *Repository) InstallDigest(d digest.Digest, file string) error
- func (r *Repository) Materialize(root string, binds map[string]digest.Digest) error
- func (r *Repository) Path(id digest.Digest) (dir, path string)
- func (r *Repository) Put(ctx context.Context, body io.Reader) (digest.Digest, error)
- func (r *Repository) ReadFrom(ctx context.Context, id digest.Digest, u *url.URL) error
- func (r *Repository) Remove(id digest.Digest) error
- func (r *Repository) Scan(ctx context.Context, handler func(digest.Digest) error) error
- func (r *Repository) Stat(ctx context.Context, id digest.Digest) (reflow.File, error)
- func (r *Repository) TempFile(prefix string) (*os.File, error)
- func (r *Repository) URL() *url.URL
- func (r *Repository) Vacuum(ctx context.Context, repo *Repository) error
- func (r *Repository) WriteTo(ctx context.Context, id digest.Digest, u *url.URL) error
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 ¶
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 ¶
func (r *Repository) Get(ctx context.Context, id digest.Digest) (io.ReadCloser, error)
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 ¶
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 ¶
Put installs an object into the repository. Its digest identity is returned.
func (*Repository) ReadFrom ¶
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) 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 ¶
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.