61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package engine
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
)
|
|
|
|
func (e *StorageEngine) exists(ctx context.Context, addr oid.Address, parentAddr oid.Address) (bool, bool, error) {
|
|
var shPrm shard.ExistsPrm
|
|
shPrm.SetAddress(addr)
|
|
shPrm.SetParentAddress(parentAddr)
|
|
alreadyRemoved := false
|
|
exists := false
|
|
locked := false
|
|
|
|
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
|
|
res, err := sh.Exists(ctx, shPrm)
|
|
if err != nil {
|
|
if client.IsErrObjectAlreadyRemoved(err) {
|
|
alreadyRemoved = true
|
|
|
|
return true
|
|
}
|
|
|
|
var siErr *objectSDK.SplitInfoError
|
|
if errors.As(err, &siErr) {
|
|
return true
|
|
}
|
|
|
|
if shard.IsErrObjectExpired(err) {
|
|
return true
|
|
}
|
|
|
|
if !client.IsErrObjectNotFound(err) {
|
|
e.reportShardError(sh, "could not check existence of object in shard", err)
|
|
}
|
|
return false
|
|
}
|
|
|
|
if !exists {
|
|
exists = res.Exists()
|
|
}
|
|
if !locked {
|
|
locked = res.Locked()
|
|
}
|
|
|
|
return false
|
|
})
|
|
|
|
if alreadyRemoved {
|
|
return false, false, new(apistatus.ObjectAlreadyRemoved)
|
|
}
|
|
|
|
return exists, locked, nil
|
|
}
|