autobee 2.11.5 → 2.11.7
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 +2 -1
- package/lib/migrations.js +4 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -732,7 +732,8 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
732
732
|
}
|
|
733
733
|
|
|
734
734
|
async _shouldReindex(key, { unknown = false, length = 0, timeout = 0 } = {}) {
|
|
735
|
-
|
|
735
|
+
// an inactive session never attaches to a peer, so fetching needs an active one
|
|
736
|
+
const core = this.store.get({ key, active: unknown && length > 0 })
|
|
736
737
|
|
|
737
738
|
try {
|
|
738
739
|
await core.ready()
|
package/lib/migrations.js
CHANGED
|
@@ -404,13 +404,13 @@ async function mapReindexedView(auto, from, prefetch) {
|
|
|
404
404
|
news.push(head)
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
|
|
407
|
+
assert(news.length === olds.length, 'Reindexed view is missing changes')
|
|
408
408
|
|
|
409
409
|
const moved = new Map()
|
|
410
|
+
const empty = { key: to.key, length: 0 }
|
|
410
411
|
|
|
411
412
|
for (let i = 0; i < olds.length; i++) {
|
|
412
413
|
moved.set(headId(olds[i]), news[i])
|
|
413
|
-
moved.set(headId({ key: olds[i].key, length: 0 }), { key: to.key, length: 0 })
|
|
414
414
|
}
|
|
415
415
|
|
|
416
416
|
return function (key, value) {
|
|
@@ -420,7 +420,8 @@ async function mapReindexedView(auto, from, prefetch) {
|
|
|
420
420
|
if (info.version <= LEGACY_AUTOBASE_VERSION) return null
|
|
421
421
|
if (!info.view || !info.view.key) return null
|
|
422
422
|
|
|
423
|
-
|
|
423
|
+
// an empty view is recorded under the local key of whoever flushed it
|
|
424
|
+
const view = info.view.length === 0 ? empty : moved.get(headId(info.view))
|
|
424
425
|
if (!view) return null
|
|
425
426
|
|
|
426
427
|
info.view = view
|