hypercore 10.31.4 → 10.31.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -2
- package/lib/core.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -985,8 +985,7 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
985
985
|
} = typeof opts === 'number' ? { fork: opts } : opts
|
|
986
986
|
|
|
987
987
|
const writable = !this._readonly && !!(signature || (keyPair && keyPair.secretKey))
|
|
988
|
-
|
|
989
|
-
if (writable === false) throw SESSION_NOT_WRITABLE()
|
|
988
|
+
if (writable === false && (newLength > 0 || fork !== this.core.tree.fork)) throw SESSION_NOT_WRITABLE()
|
|
990
989
|
|
|
991
990
|
await this.core.truncate(newLength, fork, { keyPair, signature })
|
|
992
991
|
|
package/lib/core.js
CHANGED
|
@@ -375,7 +375,7 @@ module.exports = class Core {
|
|
|
375
375
|
|
|
376
376
|
try {
|
|
377
377
|
const batch = await this.tree.truncate(length, fork)
|
|
378
|
-
batch.signature = signature || this.verifier.sign(batch, keyPair)
|
|
378
|
+
if (length > 0) batch.signature = signature || this.verifier.sign(batch, keyPair)
|
|
379
379
|
await this._truncate(batch, null)
|
|
380
380
|
} finally {
|
|
381
381
|
this.truncating--
|