aboutsummaryrefslogtreecommitdiff
path: root/objectstore/packed/new.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-08 15:33:36 +0800
committerGravatar Runxi Yu2026-03-08 15:44:32 +0800
commitdd027e1e5379019bfeffc48ff1274b5e05581ff3 (patch)
tree1f6b8f55957e706eeed801079ab42f3069085746 /objectstore/packed/new.go
parentformat/pack/ingest: Thin fix error handling (diff)
signatureNo signature
objectstore: Refresh v0.1.80
* Add manual Refresh for various objectstore's * RefreshPolicy option * Refreshable MRU and atomic snapshotting
Diffstat (limited to 'objectstore/packed/new.go')
-rw-r--r--objectstore/packed/new.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/objectstore/packed/new.go b/objectstore/packed/new.go
index 407bc1d0..c8e7338e 100644
--- a/objectstore/packed/new.go
+++ b/objectstore/packed/new.go
@@ -1,24 +1,31 @@
package packed
import (
+ "fmt"
"os"
"codeberg.org/lindenii/furgit/objectid"
)
// New creates a packed-object store rooted at an objects/pack directory.
-func New(root *os.Root, algo objectid.Algorithm) (*Store, error) {
+func New(root *os.Root, algo objectid.Algorithm, opts Options) (*Store, error) {
if algo.Size() == 0 {
return nil, objectid.ErrInvalidAlgorithm
}
+ switch opts.RefreshPolicy {
+ case RefreshPolicyOnMissing, RefreshPolicyNever:
+ default:
+ return nil, fmt.Errorf("objectstore/packed: invalid refresh policy %d", opts.RefreshPolicy)
+ }
+
return &Store{
- root: root,
- algo: algo,
- candidateByPack: make(map[string]packCandidate),
- candidateNodeByPack: make(map[string]*packCandidateNode),
- idxByPack: make(map[string]*idxFile),
- packs: make(map[string]*packFile),
- deltaCache: newDeltaCache(defaultDeltaCacheMaxBytes),
+ root: root,
+ algo: algo,
+ refreshPolicy: opts.RefreshPolicy,
+ mruNodeByPack: make(map[string]*packCandidateNode),
+ idxByPack: make(map[string]*idxFile),
+ packs: make(map[string]*packFile),
+ deltaCache: newDeltaCache(defaultDeltaCacheMaxBytes),
}, nil
}