Skip to content

Commit 41a4bcb

Browse files
committed
Forgot about clear()
1 parent d757046 commit 41a4bcb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

abstract-level.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,26 @@ class AbstractLevel extends EventEmitter {
752752

753753
const original = options
754754
const keyEncoding = this.keyEncoding(options.keyEncoding)
755+
const snapshot = options.snapshot != null ? options.snapshot : null
755756

756757
options = rangeOptions(options, keyEncoding)
757758
options.keyEncoding = keyEncoding.format
758759

759760
if (options.limit !== 0) {
760-
await this._clear(options)
761+
// Keep snapshot open during operation
762+
if (snapshot !== null) {
763+
snapshot.ref()
764+
}
765+
766+
try {
767+
await this._clear(options)
768+
} finally {
769+
// Release snapshot
770+
if (snapshot !== null) {
771+
snapshot.unref()
772+
}
773+
}
774+
761775
this.emit('clear', original)
762776
}
763777
}

0 commit comments

Comments
 (0)