writecache: Fix panic on Get
when it is not initialized #987
2 changed files with 11 additions and 5 deletions
|
@ -173,8 +173,9 @@ func (s *Shard) Init(ctx context.Context) error {
|
|||
s.gc.init(ctx)
|
||||
|
||||
s.rb = newRebuilder(s.rebuildLimiter)
|
||||
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
|
||||
|
||||
if !m.NoMetabase() {
|
||||
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -327,9 +328,11 @@ func (s *Shard) Reload(ctx context.Context, opts ...Option) error {
|
|||
defer unlock()
|
||||
|
||||
s.rb.Stop(s.log)
|
||||
defer func() {
|
||||
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
|
||||
}()
|
||||
if !s.info.Mode.NoMetabase() {
|
||||
defer func() {
|
||||
s.rb.Start(ctx, s.blobStor, s.metaBase, s.log)
|
||||
}()
|
||||
}
|
||||
|
||||
ok, err := s.metaBase.Reload(c.metaOpts...)
|
||||
if err != nil {
|
||||
|
|
|
@ -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.
|
||||
func Get(db *bbolt.DB, key []byte) ([]byte, error) {
|
||||
if db == nil {
|
||||
return nil, ErrNotInitialized
|
||||
}
|
||||
var value []byte
|
||||
err := db.View(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(defaultBucket)
|
||||
|
|
Loading…
Reference in a new issue