Documentation
¶
Overview ¶
Package git_lfs implements a git-lfs standalone custom transfer agent that stores Git LFS objects in a Store.
git-lfs starts the agent once per transfer batch when the repository sets lfs.standalonetransferagent, and exchanges one JSON object per line on the agent's stdin and stdout. See https://github.com/git-lfs/git-lfs/blob/main/docs/custom-transfers.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidOid is returned when an oid is not a SHA-256 hex digest. ErrInvalidOid = errors.New("git-lfs: oid must be 64 lowercase hex characters") // ErrOidMismatch is returned when downloaded bytes hash to another oid. ErrOidMismatch = errors.New("git-lfs: downloaded object does not match its oid") // ErrSizeMismatch is returned when a download has the wrong length. ErrSizeMismatch = errors.New("git-lfs: downloaded object has the wrong size") )
Functions ¶
func ObjectPath ¶
ObjectPath returns the slash path of oid within the UnixFS object: objects/<oid[0:2]>/<oid[2:4]>/<oid>, the layout git-lfs uses locally. The two-level shard keeps each directory small.
func ValidateOid ¶
ValidateOid checks that oid is a SHA-256 digest in lowercase hex, the form git-lfs uses, so it is safe to use as a path component.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent serves the git-lfs standalone custom transfer protocol over a Store.
func NewAgent ¶
NewAgent constructs an Agent that stores objects in store and writes downloads into tmpDir.
type Store ¶
type Store interface {
// Has reports whether the Store holds oid with exactly size bytes.
Has(ctx context.Context, oid string, size int64) (bool, error)
// Put stores size bytes read from rdr as oid, replacing an entry of
// another size. The object becomes visible only when Put succeeds.
Put(ctx context.Context, oid string, size int64, rdr io.Reader) error
// Get writes the size bytes of oid to w in order.
Get(ctx context.Context, oid string, size int64, w io.Writer) error
}
Store holds Git LFS objects addressed by their SHA-256 oid.
The Agent validates every oid before calling a Store, so an oid is always 64 lowercase hexadecimal characters.
type UnixFSStore ¶
type UnixFSStore struct {
// contains filtered or unexported fields
}
UnixFSStore stores Git LFS objects as files in a UnixFS object at ObjectPath, through the object's root handle resource.
Each Put is one UploadTree call, so the blob is ingested outside the object's write lock and the file and its shard directories land in one commit. Concurrent Puts from several agents overlap their ingest.
func NewUnixFSStore ¶
func NewUnixFSStore( root s4wave_unixfs.SRPCFSHandleResourceServiceClient, res *resource_client.Client, ) *UnixFSStore
NewUnixFSStore constructs a UnixFSStore over the root handle of a UnixFS object and the resource client that owns it.