diff options
| author | 2026-03-22 18:00:22 +0000 | |
|---|---|---|
| committer | 2026-03-22 18:02:10 +0000 | |
| commit | 4e43d7207bf91ee759c770de1bcc8562a71b4aca (patch) | |
| tree | 2abf7592a88d733b2815fc214ba59c3b209d3fa7 /objectstore | |
| parent | objectstore{,/packed}: Document lifetime and integrity behavior (diff) | |
| signature | No signature | |
objectstore/*, repository, receivepack/service: don't take ownership of root
Diffstat (limited to 'objectstore')
| -rw-r--r-- | objectstore/loose/store.go | 10 | ||||
| -rw-r--r-- | objectstore/packed/close.go | 8 | ||||
| -rw-r--r-- | objectstore/packed/store.go | 4 |
3 files changed, 7 insertions, 15 deletions
diff --git a/objectstore/loose/store.go b/objectstore/loose/store.go index 11f17594..5cb83968 100644 --- a/objectstore/loose/store.go +++ b/objectstore/loose/store.go @@ -12,12 +12,10 @@ import ( // Loose objects are zlib streams whose trailer uses Adler-32. Which reads // consume enough of the stream to reach and verify that trailer is documented // on the individual methods. -// -// Store owns root and closes it in Close. type Store struct { // root is the objects directory capability used for all object file access. // Object files are opened by relative paths like "<first2>/<rest>". - // Store owns this root. + // Store borrows this root. root *os.Root // algo is the expected object ID algorithm for lookups. algo objectid.Algorithm @@ -37,7 +35,7 @@ func New(root *os.Root, algo objectid.Algorithm) (*Store, error) { // Close releases resources associated with the backend. // +// Store borrows its root, so Close does not close it. +// // Repeated calls to Close are undefined behavior. -func (store *Store) Close() error { - return store.root.Close() -} +func (store *Store) Close() error { return nil } diff --git a/objectstore/packed/close.go b/objectstore/packed/close.go index d83245c5..f810f42c 100644 --- a/objectstore/packed/close.go +++ b/objectstore/packed/close.go @@ -2,10 +2,11 @@ package packed // Close releases mapped pack/index resources associated with the store. // +// Store borrows its root, so Close does not close it. +// // Repeated calls to Close are undefined behavior. func (store *Store) Close() error { store.stateMu.Lock() - root := store.root packs := store.packs store.stateMu.Unlock() store.idxMu.RLock() @@ -32,10 +33,5 @@ func (store *Store) Close() error { store.deltaCache.clear() store.cacheMu.Unlock() - err := root.Close() - if err != nil && closeErr == nil { - closeErr = err - } - return closeErr } diff --git a/objectstore/packed/store.go b/objectstore/packed/store.go index 58534709..61ccdb9a 100644 --- a/objectstore/packed/store.go +++ b/objectstore/packed/store.go @@ -11,10 +11,8 @@ import ( ) // Store reads Git objects from pack/index files under an objects/pack root. -// -// Store owns root and closes it in Close. type Store struct { - // root is the objects/pack capability used for all file access. + // 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 |
