From e800ee7472a2c4db4533335456f36044d86b69db Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 8 Oct 2024 13:06:46 +0200 Subject: [PATCH 1/2] remove unused args --- lib/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index 4790f3cd..780d9217 100644 --- a/lib/core.js +++ b/lib/core.js @@ -468,7 +468,7 @@ module.exports = class Core { const sharedLength = Math.min(treeLength, tree.length) - return new SessionState(this, storage, this.blocks, tree, bitfield, sharedLength, null, null) + return new SessionState(this, storage, this.blocks, tree, bitfield, sharedLength) } static async open (db, opts = {}) { From 79aac977e9f2026464b3e5a907527f31a4eda871 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 8 Oct 2024 13:20:42 +0200 Subject: [PATCH 2/2] fix own length when core is empty --- lib/core.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index 780d9217..2e4d5415 100644 --- a/lib/core.js +++ b/lib/core.js @@ -705,7 +705,9 @@ module.exports = class Core { batch.nodes = srcNodes - if (this.header.tree.length < srcBatch.length) { + const ownLength = this.header.tree === null ? 0 : this.header.tree.length + + if (ownLength < srcBatch.length) { batch.upgraded = true batch.length = srcBatch.length batch.byteLength = srcBatch.byteLength