aboutsummaryrefslogtreecommitdiff
path: root/object/storer/packed/store.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-25 14:34:50 +0000
committerGravatar Runxi Yu2026-03-25 14:34:50 +0000
commite4a7aa0742f5070299d37e8421c99d67f0af3f90 (patch)
tree36d89781476a92e61280c5ff232a2773e4092c0e /object/storer/packed/store.go
parent*: delta -> packfile/delta (diff)
signatureNo signature
*: object/store -> object/storer v0.1.107
Diffstat (limited to 'object/storer/packed/store.go')
-rw-r--r--object/storer/packed/store.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/object/storer/packed/store.go b/object/storer/packed/store.go
new file mode 100644
index 00000000..a95bedd7
--- /dev/null
+++ b/object/storer/packed/store.go
@@ -0,0 +1,51 @@
+// Package packed provides packfile reading and associated indexes.
+package packed
+
+import (
+ "os"
+ "sync"
+ "sync/atomic"
+
+ objectid "codeberg.org/lindenii/furgit/object/id"
+ "codeberg.org/lindenii/furgit/object/storer"
+)
+
+// Store reads Git objects from pack/index files under an objects/pack root.
+//
+// Store borrows its root. Cached pack/index mappings are retained until Close.
+type Store struct {
+ // root is the borrowed objects/pack capability used for all file access.
+ root *os.Root
+ // algo is the expected object ID algorithm for lookups.
+ algo objectid.Algorithm
+ // refreshPolicy controls automatic candidate refresh on lookup misses.
+ refreshPolicy RefreshPolicy
+
+ // candidates stores the latest immutable candidate snapshot.
+ candidates atomic.Pointer[candidateSnapshot]
+ // refreshMu serializes candidate refresh.
+ refreshMu sync.Mutex
+ // mruMu guards candidate MRU linked-list state.
+ mruMu sync.RWMutex
+ // mruHead is the first pack in MRU order.
+ mruHead *packCandidateNode
+ // mruTail is the last pack in MRU order.
+ mruTail *packCandidateNode
+ // mruNodeByPack maps pack basename to MRU node.
+ mruNodeByPack map[string]*packCandidateNode
+ // idxByPack caches opened and parsed indexes by pack basename.
+ idxByPack map[string]*idxFile
+
+ // stateMu guards pack cache and close state.
+ stateMu sync.RWMutex
+ // idxMu guards parsed index cache.
+ idxMu sync.RWMutex
+ // cacheMu guards delta cache operations.
+ cacheMu sync.RWMutex
+ // packs caches opened .pack handles by basename.
+ packs map[string]*packFile
+ // deltaCache caches resolved base objects by pack location.
+ deltaCache *deltaCache
+}
+
+var _ objectstorer.Store = (*Store)(nil)