Artifact 9d2da73f6472e23a7afa9a21fe48ca8762b94e8f460dd50c3e97101b1b99b7b2:
- File
repo_sparse.go
— part of check-in
[6012d82bd6]
at
2026-10-21 11:45:38
on branch feat/submanifest-reader
— feat(sync): serve partial-mirror clones from the partial-mirror setting
A sparse store refuses a clone its cone does not cover unless the boolean partial-mirror repository setting is on, read as fossil reads a boolean setting. It reaches HandleSync, XferHandler, ServeHTTP and repo serve alike; libfossil.SettingPartialMirror names it. Closes SC-5.3-2. (user: [email protected], size: 1781) [annotate] [blame] [check-ins using]
package libfossil import ( "fmt" "github.com/danmestas/go-libfossil/internal/content" internalsync "github.com/danmestas/go-libfossil/internal/sync" ) // SettingPartialMirror names the boolean repository setting, read as fossil // reads one ("on", "yes", "true" or a nonzero number), that lets a sparse store // serve a clone its cone does not cover (draft-fossil-sparse-cone-00 §5.3). // Unset, such a clone is refused with one error card and no content, since // the clone would receive elided phantoms it must resolve elsewhere. It // governs every serving surface: HandleSync, XferHandler and ServeHTTP. const SettingPartialMirror = internalsync.SettingPartialMirror // StoreCone returns the repository's store cone, or nil when the store is // dense. A store cone (draft-fossil-sparse-cone-00 §5) is local policy: an // artifact the cone leaves out may be deliberately absent, an elided phantom, // which synchronization does not request and verification counts apart from // damage. A cone this version cannot read is lost policy and reads as nil, so // the store heals toward dense. func (r *Repo) StoreCone() (*Cone, error) { inner, err := content.StoreCone(r.inner.DB()) if err != nil { return nil, fmt.Errorf("libfossil: store cone: %w", err) } return wrapCone(inner), nil } // SetStoreCone replaces the store cone; nil makes the store dense. It moves // no content. Narrowing deletes nothing (§5.4). Widening makes the newly // covered elided phantoms wanted again, and the next pull fetches them. // While a cone is set, a commit carries no R card (§4.3). func (r *Repo) SetStoreCone(c *Cone) error { if err := content.SetStoreCone(r.inner.DB(), unwrapCone(c)); err != nil { return fmt.Errorf("libfossil: set store cone: %w", err) } return nil }