From a64316152e59c3d402f9904521aca9fbdf684f98 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 8 Jun 2026 13:29:24 +0000 Subject: object/store/packed: Add stubs --- object/store/packed/doc.go | 4 +++ object/store/packed/packed.go | 36 +++++++++++++++++++++++++ object/store/packed/quarantine.go | 57 +++++++++++++++++++++++++++++++++++++++ object/store/packed/reader.go | 30 +++++++++++++++++++++ object/store/packed/writer.go | 10 +++++++ 5 files changed, 137 insertions(+) create mode 100644 object/store/packed/doc.go create mode 100644 object/store/packed/packed.go create mode 100644 object/store/packed/quarantine.go create mode 100644 object/store/packed/reader.go create mode 100644 object/store/packed/writer.go (limited to 'object') diff --git a/object/store/packed/doc.go b/object/store/packed/doc.go new file mode 100644 index 00000000..8c2a5bdc --- /dev/null +++ b/object/store/packed/doc.go @@ -0,0 +1,4 @@ +// Package packed provides Git object reading from, +// and pack writing to, +// an objects/pack directory. +package packed diff --git a/object/store/packed/packed.go b/object/store/packed/packed.go new file mode 100644 index 00000000..a70f9967 --- /dev/null +++ b/object/store/packed/packed.go @@ -0,0 +1,36 @@ +package packed + +import ( + "os" + + "lindenii.org/go/furgit/object/id" + "lindenii.org/go/furgit/object/store" +) + +// Packed reads Git objects from pack/index files under an objects/pack root, +// and ingests incoming pack streams into it. +// +// Labels: Close-Caller. +type Packed struct { + // root is the objects/pack directory capability + // used for all pack and index file access. + // Packed borrows this root. + root *os.Root + // objectFormat is the expected object format for lookups. + objectFormat id.ObjectFormat +} + +var ( + _ store.ObjectReader = (*Packed)(nil) + _ store.PackWriter = (*Packed)(nil) +) + +// New creates a packed-object store rooted at an objects/pack directory. +// +// Labels: Deps-Borrowed, Life-Parent. +func New(root *os.Root, objectFormat id.ObjectFormat) (*Packed, error) + +// Close releases mapped pack/index resources associated with the store. +// +// Labels: MT-Unsafe. +func (packed *Packed) Close() error diff --git a/object/store/packed/quarantine.go b/object/store/packed/quarantine.go new file mode 100644 index 00000000..aa520945 --- /dev/null +++ b/object/store/packed/quarantine.go @@ -0,0 +1,57 @@ +package packed + +import ( + "os" + + "lindenii.org/go/furgit/object/store" +) + +var ( + _ store.PackQuarantiner = (*Packed)(nil) + _ store.PackQuarantine = (*packQuarantine)(nil) +) + +// packQuarantine is one quarantined packed store +// rooted privately beneath a destination pack root. +type packQuarantine struct { + *Packed + + parent *Packed + tempName string + tempRoot *os.Root +} + +// BeginPackQuarantine creates one quarantined packed store +// rooted privately beneath the destination pack root. +// +// Labels: Deps-Borrowed, Life-Parent, Close-No. +func (packed *Packed) BeginPackQuarantine(opts store.PackQuarantineOptions) (store.PackQuarantine, error) + +// Discard removes the quarantine +// and invalidates the receiver. +func (quarantine *packQuarantine) Discard() error + +// Promote publishes all finalized pack artifacts in the quarantine +// into the parent packed store, +// and invalidates the receiver. +func (quarantine *packQuarantine) Promote() error + +// promoteAll links every pack artifact in the quarantine +// into the parent packed store, +// in pack/rev/idx dependency order. +func (quarantine *packQuarantine) promoteAll() error + +// promoteFile links one quarantined pack artifact +// into the parent packed store, +// treating an already-present destination as success. +func (quarantine *packQuarantine) promoteFile(name string) error + +// createPackQuarantineRoot creates a private quarantine directory +// beneath parent, +// and returns its name and an os.Root over it. +func createPackQuarantineRoot(parent *os.Root) (string, *os.Root, error) + +// packPromotionPriority orders pack artifacts +// so that data files are linked +// before the index that publishes them. +func packPromotionPriority(name string) int diff --git a/object/store/packed/reader.go b/object/store/packed/reader.go new file mode 100644 index 00000000..c876b2ef --- /dev/null +++ b/object/store/packed/reader.go @@ -0,0 +1,30 @@ +package packed + +import ( + "io" + + "lindenii.org/go/furgit/object/id" + "lindenii.org/go/furgit/object/typ" +) + +// ReadBytesFull reads a full serialized object as "type size\x00content". +func (packed *Packed) ReadBytesFull(objectID id.ObjectID) ([]byte, error) + +// ReadBytesContent reads an object's type and content bytes. +func (packed *Packed) ReadBytesContent(objectID id.ObjectID) (typ.Type, []byte, error) + +// ReadReaderFull reads a full serialized object stream as "type size\x00content". +func (packed *Packed) ReadReaderFull(objectID id.ObjectID) (io.ReadCloser, error) + +// ReadReaderContent reads an object's type, declared content length, +// and content stream. +func (packed *Packed) ReadReaderContent(objectID id.ObjectID) (typ.Type, uint64, io.ReadCloser, error) + +// ReadSize reads an object's declared content length. +func (packed *Packed) ReadSize(objectID id.ObjectID) (uint64, error) + +// ReadHeader reads an object's type and declared content length. +func (packed *Packed) ReadHeader(objectID id.ObjectID) (typ.Type, uint64, error) + +// Refresh updates the packed-store view of on-disk pack/index candidates. +func (packed *Packed) Refresh() error diff --git a/object/store/packed/writer.go b/object/store/packed/writer.go new file mode 100644 index 00000000..48a908fd --- /dev/null +++ b/object/store/packed/writer.go @@ -0,0 +1,10 @@ +package packed + +import ( + "io" + + "lindenii.org/go/furgit/object/store" +) + +// WritePack ingests one pack stream into the packed store. +func (packed *Packed) WritePack(src io.Reader, opts store.PackWriteOptions) error -- cgit v1.3.1-10-gc9f91