2022-11-17 06:06:59 +00:00
|
|
|
package blobovnicza
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
2022-11-17 06:06:59 +00:00
|
|
|
"go.etcd.io/bbolt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Exists check if object with the specified address is stored in b.
|
|
|
|
func (b *Blobovnicza) Exists(addr oid.Address) (bool, error) {
|
|
|
|
var (
|
|
|
|
exists bool
|
|
|
|
addrKey = addressKey(addr)
|
|
|
|
)
|
|
|
|
|
|
|
|
err := b.boltDB.View(func(tx *bbolt.Tx) error {
|
|
|
|
return tx.ForEach(func(_ []byte, buck *bbolt.Bucket) error {
|
|
|
|
exists = buck.Get(addrKey) != nil
|
|
|
|
if exists {
|
|
|
|
return errInterruptForEach
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
if err == errInterruptForEach {
|
|
|
|
err = nil
|
|
|
|
}
|
|
|
|
return exists, err
|
|
|
|
}
|