[#1679] node: Fix 'gocognit' warning
Some checks failed
Vulncheck / Vulncheck (push) Successful in 1m6s
Pre-commit hooks / Pre-commit (push) Successful in 1m45s
Build / Build Components (push) Successful in 2m2s
OCI image / Build container images (push) Has been cancelled
Tests and linters / Lint (push) Has been cancelled
Tests and linters / Tests with -race (push) Has been cancelled
Tests and linters / Tests (push) Has been cancelled
Tests and linters / Staticcheck (push) Has been cancelled
Tests and linters / gopls check (push) Has been cancelled
Tests and linters / Run gofumpt (push) Has been cancelled
Some checks failed
Vulncheck / Vulncheck (push) Successful in 1m6s
Pre-commit hooks / Pre-commit (push) Successful in 1m45s
Build / Build Components (push) Successful in 2m2s
OCI image / Build container images (push) Has been cancelled
Tests and linters / Lint (push) Has been cancelled
Tests and linters / Tests with -race (push) Has been cancelled
Tests and linters / Tests (push) Has been cancelled
Tests and linters / Staticcheck (push) Has been cancelled
Tests and linters / gopls check (push) Has been cancelled
Tests and linters / Run gofumpt (push) Has been cancelled
Change-Id: I6e2a278af51869c05c306c2910ba85130e39532e Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
0c5d74729c
commit
b4b053cecd
1 changed files with 19 additions and 10 deletions
|
@ -84,17 +84,11 @@ func (e *StorageEngine) lockSingle(ctx context.Context, idCnr cid.ID, locker, lo
|
|||
var siErr *objectSDK.SplitInfoError
|
||||
var eiErr *objectSDK.ECInfoError
|
||||
if errors.As(err, &eiErr) {
|
||||
eclocked := []oid.ID{locked}
|
||||
for _, chunk := range eiErr.ECInfo().Chunks {
|
||||
var objID oid.ID
|
||||
err = objID.ReadFromV2(chunk.ID)
|
||||
if err != nil {
|
||||
e.reportShardError(ctx, sh, "could not lock object in shard", err, zap.Stringer("container_id", idCnr),
|
||||
zap.Stringer("locker_id", locker), zap.Stringer("locked_id", locked))
|
||||
eclocked, ok := e.checkECLocked(ctx, sh, idCnr, locker, locked, eiErr)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
eclocked = append(eclocked, objID)
|
||||
}
|
||||
|
||||
err = sh.Lock(ctx, idCnr, locker, eclocked)
|
||||
if err != nil {
|
||||
e.reportShardError(ctx, sh, "could not lock object in shard", err, zap.Stringer("container_id", idCnr),
|
||||
|
@ -137,3 +131,18 @@ func (e *StorageEngine) lockSingle(ctx context.Context, idCnr cid.ID, locker, lo
|
|||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (e *StorageEngine) checkECLocked(ctx context.Context, sh hashedShard, idCnr cid.ID, locker, locked oid.ID, eiErr *objectSDK.ECInfoError) ([]oid.ID, bool) {
|
||||
eclocked := []oid.ID{locked}
|
||||
for _, chunk := range eiErr.ECInfo().Chunks {
|
||||
var objID oid.ID
|
||||
err := objID.ReadFromV2(chunk.ID)
|
||||
if err != nil {
|
||||
e.reportShardError(ctx, sh, "could not lock object in shard", err, zap.Stringer("container_id", idCnr),
|
||||
zap.Stringer("locker_id", locker), zap.Stringer("locked_id", locked))
|
||||
return nil, false
|
||||
}
|
||||
eclocked = append(eclocked, objID)
|
||||
}
|
||||
return eclocked, true
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue