Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.

Commit 797084a

Browse files
authored
Merge pull request #62 from ssb-ngi-pointer/protect-del
protect del() from concurrency on the latest block
2 parents 469a879 + fc72e76 commit 797084a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ module.exports = function AsyncAppendOnlyLog(filename, opts) {
206206
}
207207

208208
function del(offset, cb) {
209+
if (blocksToBeWritten.has(getBlockIndex(offset))) {
210+
onDrain(function delAfterDrained() {
211+
del(offset, cb)
212+
})
213+
return
214+
}
209215
getBlock(offset, function gotBlockForDelete(err, blockBuf) {
210216
if (err) return cb(err)
211217
Record.overwriteWithZeroes(blockBuf, getOffsetInBlock(offset))

0 commit comments

Comments
 (0)