Files
bare-operating-system/patches/autopass+3.4.0.patch
T
2026-05-27 00:00:13 +00:00

132 lines
5.5 KiB
Diff

diff --git a/node_modules/autopass/index.js b/node_modules/autopass/index.js
index 1d1e684..34a93db 100644
--- a/node_modules/autopass/index.js
+++ b/node_modules/autopass/index.js
@@ -98,7 +98,12 @@ class AutopassPairer extends ReadyResource {
}
_whenWritable() {
- if (this.pass.base.writable) return
+ // If already writable (e.g. view caught up synchronously after deleteInvite), resolve
+ // immediately. Returning without onresolve left pairer.finished() hanging forever.
+ if (this.pass.base.writable) {
+ this.onresolve(this.pass)
+ return
+ }
const check = () => {
if (this.pass.base.writable) {
this.pass.base.off('update', check)
@@ -218,7 +223,12 @@ class Autopass extends ReadyResource {
async _apply(nodes, view, base) {
for (const node of nodes) {
- await this.router.dispatch(node.value, { view, base })
+ try {
+ await this.router.dispatch(node.value, { view, base })
+ } catch (err) {
+ this.emit('error', err)
+ throw err
+ }
}
await view.flush()
}
diff --git a/node_modules/autopass/spec/db/index.js b/node_modules/autopass/spec/db/index.js
index f8bcd6e..573789d 100644
--- a/node_modules/autopass/spec/db/index.js
+++ b/node_modules/autopass/spec/db/index.js
@@ -6,6 +6,17 @@ const { version, getEncoding, setVersion } = require('./messages.js')
const versions = { schema: version, db: 1 }
+/** HyperDB v4.22+ prefixes values with type=0; older rows store version as first uint. */
+function _decodeCollectionValueHeader(state, collection) {
+ const type = c.uint.decode(state)
+ if (type !== 0) {
+ state.start = 0
+ collection.decodedVersion = type
+ return
+ }
+ collection.decodedVersion = c.uint.decode(state)
+}
+
// '@autopass/records' collection key
const collection0_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 0 })
@@ -22,9 +33,7 @@ function collection0_reconstruct(schemaVersion, keyBuf, valueBuf) {
const key = collection0_key.decode(keyBuf)
setVersion(schemaVersion)
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
- const type = c.uint.decode(state)
- if (type !== 0) throw new Error('Unknown collection type: ' + type)
- collection0.decodedVersion = c.uint.decode(state)
+ _decodeCollectionValueHeader(state, collection0)
const record = collection0_enc.decode(state)
record.key = key[0]
return record
@@ -87,9 +96,7 @@ function collection1_reconstruct(schemaVersion, keyBuf, valueBuf) {
const key = collection1_key.decode(keyBuf)
setVersion(schemaVersion)
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
- const type = c.uint.decode(state)
- if (type !== 0) throw new Error('Unknown collection type: ' + type)
- collection1.decodedVersion = c.uint.decode(state)
+ _decodeCollectionValueHeader(state, collection1)
const record = collection1_enc.decode(state)
record.id = key[0]
return record
@@ -152,9 +159,7 @@ function collection2_reconstruct(schemaVersion, keyBuf, valueBuf) {
const key = collection2_key.decode(keyBuf)
setVersion(schemaVersion)
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
- const type = c.uint.decode(state)
- if (type !== 0) throw new Error('Unknown collection type: ' + type)
- collection2.decodedVersion = c.uint.decode(state)
+ _decodeCollectionValueHeader(state, collection2)
const record = collection2_enc.decode(state)
record.key = key[0]
return record
@@ -217,9 +222,7 @@ function collection3_reconstruct(schemaVersion, keyBuf, valueBuf) {
const key = collection3_key.decode(keyBuf)
setVersion(schemaVersion)
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
- const type = c.uint.decode(state)
- if (type !== 0) throw new Error('Unknown collection type: ' + type)
- collection3.decodedVersion = c.uint.decode(state)
+ _decodeCollectionValueHeader(state, collection3)
const record = collection3_enc.decode(state)
record.key = key[0]
return record
@@ -282,9 +285,7 @@ function collection4_reconstruct(schemaVersion, keyBuf, valueBuf) {
const key = collection4_key.decode(keyBuf)
setVersion(schemaVersion)
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
- const type = c.uint.decode(state)
- if (type !== 0) throw new Error('Unknown collection type: ' + type)
- collection4.decodedVersion = c.uint.decode(state)
+ _decodeCollectionValueHeader(state, collection4)
const record = collection4_enc.decode(state)
record.key = key[0]
return record
@@ -347,9 +348,7 @@ function collection5_reconstruct(schemaVersion, keyBuf, valueBuf) {
const key = collection5_key.decode(keyBuf)
setVersion(schemaVersion)
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
- const type = c.uint.decode(state)
- if (type !== 0) throw new Error('Unknown collection type: ' + type)
- collection5.decodedVersion = c.uint.decode(state)
+ _decodeCollectionValueHeader(state, collection5)
const record = collection5_enc.decode(state)
record.id = key[0]
return record
@@ -412,9 +411,7 @@ function collection6_reconstruct(schemaVersion, keyBuf, valueBuf) {
const key = collection6_key.decode(keyBuf)
setVersion(schemaVersion)
const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
- const type = c.uint.decode(state)
- if (type !== 0) throw new Error('Unknown collection type: ' + type)
- collection6.decodedVersion = c.uint.decode(state)
+ _decodeCollectionValueHeader(state, collection6)
const record = collection6_enc.decode(state)
record.key = key[0]
return record