Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/engine/bee.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class BeeSnapshot {
constructor (snap, onfree) {
this.refs = 1
this.snapshot = snap
this.batch = snap.batch()
this.opened = false
this.onfree = onfree
}
Expand All @@ -25,6 +26,7 @@ class BeeSnapshot {

unref () {
if (--this.refs === 0) {
this.batch.close().catch(noop)
this.snapshot.close().then(this.onfree, this.onfree)
this.snapshot = null
}
Expand All @@ -39,7 +41,7 @@ class BeeSnapshot {

for (let i = 0; i < promises.length; i++) {
const { key, value } = entries[i]
promises[i] = getWrapped(this.snapshot, key, reconstruct(key, value), checkout, reqs)
promises[i] = getWrapped(this.batch, key, reconstruct(key, value), checkout, reqs)
}

return promises
Expand All @@ -49,14 +51,14 @@ class BeeSnapshot {
const promises = new Array(keys.length)

for (let i = 0; i < keys.length; i++) {
promises[i] = getValue(this.snapshot, keys[i], checkout, reqs)
promises[i] = getValue(this.batch, keys[i], checkout, reqs)
}

return Promise.all(promises)
}

get (key, checkout, reqs) {
return getValue(this.snapshot, key, checkout, reqs)
return getValue(this.batch, key, checkout, reqs)
}

createReadStream (range, options) {
Expand Down
Loading