package blobtree import ( "context" "encoding/binary" "errors" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" ) func (b *BlobTree) Exists(_ context.Context, prm common.ExistsPrm) (common.ExistsRes, error) { if len(prm.StorageID) == storageIDLength { return b.existsFromIdx(prm.Address, binary.LittleEndian.Uint64(prm.StorageID)) } return b.findAndCheck(prm.Address) } func (b *BlobTree) existsFromIdx(addr oid.Address, idx uint64) (common.ExistsRes, error) { dir := b.getDirectoryPath(addr) path := b.getFilePath(dir, idx) b.fileLock.RLock(path) defer b.fileLock.RUnlock(path) records, err := b.readFileContent(path) if err != nil { return common.ExistsRes{}, err } for i := range records { if records[i].Address.Equals(addr) { return common.ExistsRes{ Exists: true, }, nil } } return common.ExistsRes{}, nil } func (b *BlobTree) findAndCheck(addr oid.Address) (common.ExistsRes, error) { dir := b.getDirectoryPath(addr) _, err := b.findFileIdx(dir, addr) if err != nil { var notFound *apistatus.ObjectNotFound if errors.As(err, ¬Found) { return common.ExistsRes{}, nil } return common.ExistsRes{}, err } return common.ExistsRes{Exists: true}, nil }