mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-18 01:27:15 +00:00
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
|
||||
treeCid = manifest.treeCid
|
||||
|
||||
var
|
||||
deleted = 0
|
||||
|
||||
for index in blockIndices:
|
||||
if index >= 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)
|
||||
if not hasBlock:
|
||||
return failure("Tree does not have this index: " & $index & " totalBlocks: " & $totalBlocks)
|
||||
else:
|
||||
if err =? (await self.networkStore.delBlock(treeCid, index)).errorOption:
|
||||
return failure(err)
|
||||
inc deleted
|
||||
|
||||
var deleted = 0
|
||||
for index in blockIndices:
|
||||
if err =? (await self.networkStore.delBlock(treeCid, index)).errorOption:
|
||||
return failure(err)
|
||||
inc deleted
|
||||
|
||||
return success(deleted)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user