lfs

package
v0.0.0-...-bd25097 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

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 lfs stores Git LFS objects (D82): content-addressed files per repository under data/lfs, written only after their sha256 and size are checked. Objects never change once written, so a backup can hard-link them and a fork can share them without copying bytes.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMismatch = errors.New("lfs: content does not match its oid or size")
	ErrTooLarge = errors.New("lfs: object larger than the limit")
)

Errors an upload maps to answers.

Functions

func IsAuth

func IsAuth(tok string) bool

IsAuth reports whether a bearer value is an SSH LFS token (and not an access token).

func SignAuth

func SignAuth(key []byte, userID, repoID int64, write bool, exp time.Time) string

SignAuth makes a token for a person, a repository and a direction.

func ValidOID

func ValidOID(s string) bool

ValidOID reports whether s is a sha256 object id in lower-case hex.

func VerifyAuth

func VerifyAuth(key []byte, tok string, now time.Time) (userID, repoID int64, write, ok bool)

VerifyAuth checks a token's signature and expiry.

Types

type Pointer

type Pointer struct {
	OID  string
	Size int64
}

Pointer is a parsed LFS pointer file.

func ParsePointer

func ParsePointer(b []byte) (Pointer, bool)

ParsePointer recognises a Git LFS pointer file (spec v1): a version line, then sorted key/value lines including "oid sha256:<hex>" and "size <n>". Anything else is ordinary content.

type Store

type Store struct{ Root string }

Store is the object store; Root is data/lfs.

func (Store) Delete

func (s Store) Delete(repoID int64) error

Delete removes every object of a repository (the repository was deleted).

func (Store) LinkAll

func (s Store) LinkAll(from int64, to Store, toID int64) (int, error)

LinkAll makes every object of one repository available in another (a fork, a merge from a fork, a backup): a hard link when both are on one filesystem, a copy otherwise. Objects the target has already are left alone.

func (Store) Open

func (s Store) Open(repoID int64, oid string) (*os.File, error)

Open opens a stored object for reading.

func (Store) Path

func (s Store) Path(repoID int64, oid string) string

Path is where an object of a repository lives. oid must be valid (callers check ValidOID).

func (Store) Put

func (s Store) Put(repoID int64, oid string, size, limit int64, r io.Reader) error

Put writes an object from r, at most limit bytes (0 = no limit). The bytes go to a temporary file first; only when their sha256 equals oid (and the size equals size, when size >= 0) is the file moved into place, so a half upload or a lie about the content never becomes an object.

func (Store) Repos

func (s Store) Repos() ([]int64, error)

Repos lists the repository ids that have an object folder (backup).

func (Store) Stat

func (s Store) Stat(repoID int64, oid string) (int64, bool)

Stat returns the size of a stored object.

func (Store) Usage

func (s Store) Usage(repoID int64) (count int, bytes int64, err error)

Usage counts a repository's objects and bytes.

func (Store) Verify

func (s Store) Verify(repoID int64) (bad []string, err error)

Verify checks every object of a repository against its name (restore drill). It returns the oids that do not match.

Jump to

Keyboard shortcuts

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