forked from TrueCloudLab/frostfs-node
1667ec9e6d
`object.Address` has been moved to `object/address` `object.ID` has been moved to `object/id` Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
40 lines
857 B
Go
40 lines
857 B
Go
package engine
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
|
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
|
)
|
|
|
|
func (e *StorageEngine) exists(addr *addressSDK.Address) (bool, error) {
|
|
shPrm := new(shard.ExistsPrm).WithAddress(addr)
|
|
alreadyRemoved := false
|
|
exists := false
|
|
|
|
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
|
|
res, err := sh.Exists(shPrm)
|
|
if err != nil {
|
|
if errors.Is(err, object.ErrAlreadyRemoved) {
|
|
alreadyRemoved = true
|
|
|
|
return true
|
|
}
|
|
|
|
e.reportShardError(sh, "could not check existence of object in shard", err)
|
|
}
|
|
|
|
if res != nil && !exists {
|
|
exists = res.Exists()
|
|
}
|
|
|
|
return false
|
|
})
|
|
|
|
if alreadyRemoved {
|
|
return false, object.ErrAlreadyRemoved
|
|
}
|
|
|
|
return exists, nil
|
|
}
|