Skip to content

Commit

Permalink
session overwrite should emit events
Browse files Browse the repository at this point in the history
  • Loading branch information
chm-diederichs committed Dec 5, 2024
1 parent 6aed98d commit bd84fb5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/session-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,14 @@ module.exports = class SessionState {
await this.mutex.lock()

try {
await this._overwrite(state, length, treeLength, null)
const origLength = this.tree.length

const tree = await this._overwrite(state, length, treeLength, null)

const bitfield = { start: treeLength, length: tree.length - treeLength, drop: false }

if (treeLength < origLength) this.ontruncate(tree, treeLength, origLength)
if (treeLength < tree.length) this.onappend(tree, bitfield)

return {
length: this.tree.length,
Expand Down

0 comments on commit bd84fb5

Please sign in to comment.