folder

package
v0.7.29 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 1 package

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 folder is the mounts driver for a folder on the server's disk. Its mounts are live and writable, and have host paths. Only the server's configuration makes folder mounts (the registry refuses one from Create), so a client never picks the folder.

Every operation refuses links anywhere in a path, so a link inside the folder can't reach a file outside it, or a second name for a file inside it. Listings leave out links, devices and anything else that isn't a regular file or a folder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver serves mounts.KindFolder mounts, whose Source is the folder's absolute path. It implements mounts.Writer, mounts.Localizer and mounts.VersionReader. It ignores credentials.

A write's IfMatch check and the write itself happen under a lock per file held in this Driver, so two writers in one process can't both pass the check. Writers in two processes, or two Drivers, can. Share one Driver per process.

func New

func New(opts ...Option) *Driver

New returns a folder driver.

func (*Driver) Delete

Delete removes req.Path when IfMatch is its current version or AnyVersion. Empty IfMatch never matches an existing file, so it returns ErrConflict. A missing file returns ErrNotFound. Delete leaves empty parent folders in place.

func (*Driver) FetchAt added in v0.7.14

func (d *Driver) FetchAt(ctx context.Context, m mounts.Mount, creds mounts.Credentials, version string, f mounts.File) (blobs.Hash, bool, error)

FetchAt reads f from the folder as it is now and keeps it in the driver's blob store. fetched is true when the store didn't hold the contents yet. version is checked as ListAt checks it.

func (*Driver) HostPath

func (d *Driver) HostPath(m mounts.Mount, p string) (string, error)

HostPath returns the absolute path of p in the folder. The file need not exist, so a native tool can write its output there. A path through a link returns ErrInvalidPath, and a file that is a Git LFS pointer returns ErrLFS. A folder's path is returned without looking at the files in it.

func (*Driver) Kind

func (d *Driver) Kind() mounts.Kind

Kind returns mounts.KindFolder.

func (*Driver) ListAt added in v0.7.14

func (d *Driver) ListAt(ctx context.Context, m mounts.Mount, creds mounts.Credentials, version, under string) ([]mounts.File, error)

ListAt walks the folder at under as it is now, or returns the one file under names. version is "" or one Resolve returned, and is ignored, since a folder can't be read as of an older version. Any other version returns ErrInvalidArgument. Links and anything else that isn't a regular file are left out, and a path through a link returns ErrInvalidPath.

func (*Driver) ListRefs added in v0.7.16

func (d *Driver) ListRefs(ctx context.Context, source string, req mounts.ListRefsRequest, creds mounts.Credentials) (mounts.RefPage, error)

ListRefs returns an empty page. A folder has no tags and no commits.

func (*Driver) Modes

func (d *Driver) Modes() []mounts.Mode

Modes returns mounts.ModeLive. A folder mount always shows the folder as it is now.

func (*Driver) Moves added in v0.7.14

func (d *Driver) Moves(ctx context.Context, source, ref string, creds mounts.Credentials) (bool, error)

Moves returns true. A folder has no history, so a sync always reads it as it is now.

func (*Driver) Open

func (d *Driver) Open(ctx context.Context, m mounts.Mount, creds mounts.Credentials) (fs.FS, error)

Open returns the folder's files as they are now. The fs.FS refuses a path through a link with an error wrapping ErrInvalidPath, and its listings leave links out, so fs.WalkDir sees only regular files and folders. Opening a Git LFS pointer fails with ErrLFS, naming the path.

func (*Driver) Put

Put writes req.Data to req.Path through a temp file and a rename, so a reader sees the old file or the new one and never part of either. It creates missing parent folders. The IfMatch check follows mounts.PutRequest. The result's Mount version is empty, since a folder has none.

func (*Driver) Resolve

func (d *Driver) Resolve(ctx context.Context, source, ref string, creds mounts.Credentials) (string, error)

Resolve checks that source is an absolute path to a folder, and returns its version: "mtime:" and a hash over each regular file's path, size and modification time (goapplib issue 178). It reads no file's contents, so an app polls it to see whether a followed folder changed, and reads the files only when the version moved. A folder has no refs, so a non-empty ref returns ErrInvalidArgument, as does a relative path or a file. A missing folder returns ErrNotFound, and one over mounts.DefaultLimits' file count returns ErrTooLarge.

func (*Driver) Stat

Stat returns the file's version, "sha256:" and the hex SHA-256 of its contents. Content hashes, unlike modification times, don't change when nothing did, and can't collide when a file changes twice in one clock tick.

type Option added in v0.7.14

type Option func(*Driver)

Option configures a Driver.

func WithBlobs added in v0.7.14

func WithBlobs(store blobs.Store) Option

WithBlobs sets the blob store FetchAt keeps files in. Without it, FetchAt returns ErrInvalidArgument.

func WithLinksInside added in v0.7.15

func WithLinksInside() Option

WithLinksInside lets reads follow a link whose target stays inside the mount's folder: listings, Open, HostPath, ListAt and FetchAt. A link that leads outside, directly or through another link, is still refused with ErrInvalidPath and left out of listings. Writes never go through a link. Without it, every link is refused, which is the default.

Jump to

Keyboard shortcuts

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