gitlfs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package gitlfs owns the content-addressed object layout of Git LFS repositories. An object is stored at objects/<first two OID characters>/<next two>/<64-character SHA-256 OID>, Artifactory's layout, and only content with that SHA-256 is admitted there; the object tree itself is the index the batch API answers from.

Role

artifacts module, ecosystem layer: the Git LFS content-addressed object layout of the Git LFS slice. Its Handler plugs into the item service through the format hooks (decision 0032), so every write in a Git LFS repository reaches it whichever API carried it; the slice's http package (artifacts/ecosystem/gitlfs/http) serves the batch, transfer and locking API over the object tree.

Inputs

  • Driving: the format registry (artifacts/ecosystem), which hands the item service's hooks for gitlfs repositories to Handler; and the protocol, which checks every OID and builds its path (ObjectPath).
  • Driven: the generic deploy policy (artifacts/ecosystem/generic), which Handler embeds and Admit applies after its own checks.
  • Settings: none.

Outputs

  • Handler: the hooks that admit only an object at its own path with its own SHA-256 (Admit), and a reindex that has nothing to rebuild (Reindex). Deploys and deletes need nothing more, because the object tree is the index.
  • ObjectPath: the object layout, and the check of an OID.

Invariants

  • An OID is 64 lower-case hexadecimal characters, a SHA-256.
  • An object's content always has the SHA-256 its path names: a write elsewhere or with other content is refused (409), and so is a client checksum sidecar.
  • Delete and restore change the batch view at once, because nothing is derived from the object tree.

References

Status

Implemented P9c, which delivered the plan's P33 group (issues #782 to #788). Moved here in P9d.

Testing

  • gitlfs_test.go: the canonical SHA-256 object path, and the refusal of writes that are not objects.

The object routes' tests in artifacts/ecosystem/gitlfs/http exercise the hooks through the item service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObjectPath

func ObjectPath(oid string) (string, bool)

ObjectPath is Artifactory's two-level SHA-256 object layout.

func Serves

func Serves(t repo.PackageType) bool

Serves reports whether t is the Git LFS package type.

Types

type Handler

type Handler struct{ generic.Handler }

Handler is the Git LFS format's hooks: it admits a write only as an object at the path its SHA-256 OID gives, and keeps no index beyond the object tree. It embeds the generic hooks, whose deploy policy Admit applies after its own checks.

func (Handler) Admit

func (h Handler) Admit(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	w format.Write,
) (format.Write, error)

Admit refuses (409) a checksum sidecar upload, which an object never takes, and any write that is not of an object at the ObjectPath of its file name with that SHA-256. A remote's copy at a path that is not an object's is kept as a plain file (format.RemoteCopy), but one at an object's path must still carry that SHA-256. Every write it admits then meets the generic deploy policy, whose refusal it wraps.

func (Handler) Reindex

Reindex does nothing: the object tree is the native index. Delete and restore change the batch view directly, so there is no derived metadata to rebuild.

Directories

Path Synopsis
Package gitlfshttp serves Git LFS batch and basic object transfers, and the Git LFS locking API, for local, remote, virtual and federated repositories on Artifactory's /artifactory/api/lfs/{repo} prefix.
Package gitlfshttp serves Git LFS batch and basic object transfers, and the Git LFS locking API, for local, remote, virtual and federated repositories on Artifactory's /artifactory/api/lfs/{repo} prefix.

Jump to

Keyboard shortcuts

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