Checks presence of all blocks before deleting
This commit is contained in:
parent
5355c0c1f6
commit
a3426a73f1
|
@ -523,9 +523,6 @@ proc debugDelete*(self: CodexNodeRef, cid: Cid, blockIndices: seq[int]): Future[
|
||||||
totalBlocks = manifest.blocksCount
|
totalBlocks = manifest.blocksCount
|
||||||
treeCid = manifest.treeCid
|
treeCid = manifest.treeCid
|
||||||
|
|
||||||
var
|
|
||||||
deleted = 0
|
|
||||||
|
|
||||||
for index in blockIndices:
|
for index in blockIndices:
|
||||||
if index >= totalBlocks:
|
if index >= totalBlocks:
|
||||||
return failure("Index out of range. Index: " & $index & " totalBlocks: " & $totalBlocks)
|
return failure("Index out of range. Index: " & $index & " totalBlocks: " & $totalBlocks)
|
||||||
|
@ -533,10 +530,12 @@ proc debugDelete*(self: CodexNodeRef, cid: Cid, blockIndices: seq[int]): Future[
|
||||||
return failure(err)
|
return failure(err)
|
||||||
if not hasBlock:
|
if not hasBlock:
|
||||||
return failure("Tree does not have this index: " & $index & " totalBlocks: " & $totalBlocks)
|
return failure("Tree does not have this index: " & $index & " totalBlocks: " & $totalBlocks)
|
||||||
else:
|
|
||||||
if err =? (await self.networkStore.delBlock(treeCid, index)).errorOption:
|
var deleted = 0
|
||||||
return failure(err)
|
for index in blockIndices:
|
||||||
inc deleted
|
if err =? (await self.networkStore.delBlock(treeCid, index)).errorOption:
|
||||||
|
return failure(err)
|
||||||
|
inc deleted
|
||||||
|
|
||||||
return success(deleted)
|
return success(deleted)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue