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

Commit 80b7f5f

Browse files
committed
improve del() against one race condition
1 parent 0a3c894 commit 80b7f5f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ module.exports = function AsyncAppendOnlyLog(filename, opts) {
262262
}
263263
function gotBlockForDelete(err, blockBuf) {
264264
if (err) return cb(err)
265-
Record.overwriteWithZeroes(blockBuf, getOffsetInBlock(offset))
266-
blocksWithDeletables.set(blockIndex, blockBuf)
265+
const actualBlockBuf = blocksWithDeletables.get(blockIndex) || blockBuf
266+
Record.overwriteWithZeroes(actualBlockBuf, getOffsetInBlock(offset))
267+
blocksWithDeletables.set(blockIndex, actualBlockBuf)
267268
scheduleFlushDelete()
268269
cb()
269270
}

0 commit comments

Comments
 (0)