aboutsummaryrefslogtreecommitdiff
path: root/refstore/reftable/store.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-21 15:29:40 +0800
committerGravatar Runxi Yu2026-02-21 15:29:40 +0800
commit673902b14458f32fbf47efa3757279872bdfcb7e (patch)
treecdcae5d8c7ee01e4931a306931fc79c01c1ea406 /refstore/reftable/store.go
parentrepository: Add passthrough ReadStored*; add ref convenience funcs (diff)
signatureNo signature
repository, {ref,object}store: Make stores own their roots
Diffstat (limited to 'refstore/reftable/store.go')
-rw-r--r--refstore/reftable/store.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/refstore/reftable/store.go b/refstore/reftable/store.go
index ac730a4b..7c02c157 100644
--- a/refstore/reftable/store.go
+++ b/refstore/reftable/store.go
@@ -15,7 +15,7 @@ import (
// Store reads references from a reftable stack rooted at $GIT_DIR/reftable.
//
-// Store does not own root. Callers are responsible for closing root.
+// Store owns root and closes it in Close.
type Store struct {
// root is the reftable directory capability.
root *os.Root
@@ -53,8 +53,8 @@ func (store *Store) Close() error {
return nil
}
store.closed = true
+ root := store.root
tables := store.tables
- store.tables = nil
store.stateMu.Unlock()
var closeErr error
@@ -66,6 +66,9 @@ func (store *Store) Close() error {
closeErr = err
}
}
+ if err := root.Close(); err != nil && closeErr == nil {
+ closeErr = err
+ }
return closeErr
}