[#959] writecache: Fix panic on Get
when it is not initialized
All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 2m41s
DCO action / DCO (pull_request) Successful in 2m43s
Tests and linters / Staticcheck (pull_request) Successful in 3m55s
Build / Build Components (1.21) (pull_request) Successful in 3m45s
Build / Build Components (1.20) (pull_request) Successful in 4m19s
Tests and linters / Lint (pull_request) Successful in 5m30s
Tests and linters / Tests (1.20) (pull_request) Successful in 7m57s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m22s
Tests and linters / Tests with -race (pull_request) Successful in 8m39s
All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 2m41s
DCO action / DCO (pull_request) Successful in 2m43s
Tests and linters / Staticcheck (pull_request) Successful in 3m55s
Build / Build Components (1.21) (pull_request) Successful in 3m45s
Build / Build Components (1.20) (pull_request) Successful in 4m19s
Tests and linters / Lint (pull_request) Successful in 5m30s
Tests and linters / Tests (1.20) (pull_request) Successful in 7m57s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m22s
Tests and linters / Tests with -race (pull_request) Successful in 8m39s
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
2429508ac5
commit
05b5f5ca85
1 changed files with 3 additions and 0 deletions
|
@ -84,6 +84,9 @@ func (c *cache) Head(ctx context.Context, addr oid.Address) (*objectSDK.Object,
|
||||||
//
|
//
|
||||||
// Returns an error of type apistatus.ObjectNotFound if the requested object is missing in db.
|
// Returns an error of type apistatus.ObjectNotFound if the requested object is missing in db.
|
||||||
func Get(db *bbolt.DB, key []byte) ([]byte, error) {
|
func Get(db *bbolt.DB, key []byte) ([]byte, error) {
|
||||||
|
if db == nil {
|
||||||
|
return nil, ErrNotInitialized
|
||||||
|
}
|
||||||
var value []byte
|
var value []byte
|
||||||
err := db.View(func(tx *bbolt.Tx) error {
|
err := db.View(func(tx *bbolt.Tx) error {
|
||||||
b := tx.Bucket(defaultBucket)
|
b := tx.Bucket(defaultBucket)
|
||||||
|
|
Loading…
Reference in a new issue