autobee 2.11.2 → 2.11.3
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 +11 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -686,10 +686,13 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
686
686
|
async compactMaybe() {
|
|
687
687
|
if (await this._isReindexed()) return
|
|
688
688
|
|
|
689
|
-
await this.
|
|
689
|
+
const latest = await this.writers.getLatestLocalOplog()
|
|
690
|
+
const views = latest ? latest.views : null
|
|
691
|
+
|
|
692
|
+
await this._reindexBee(this._workingBee, views ? views.view : null)
|
|
690
693
|
this.bee.move(this._workingBee.head())
|
|
691
694
|
|
|
692
|
-
await this._reindexBee(this.system.bee)
|
|
695
|
+
await this._reindexBee(this.system.bee, views ? views.system : null)
|
|
693
696
|
|
|
694
697
|
this._reindexed = true
|
|
695
698
|
}
|
|
@@ -704,17 +707,18 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
704
707
|
return !(await this._shouldReindex(view.key))
|
|
705
708
|
}
|
|
706
709
|
|
|
707
|
-
async _reindexBee(bee) {
|
|
710
|
+
async _reindexBee(bee, flushed) {
|
|
708
711
|
const head = bee.head()
|
|
709
712
|
const local = bee.context.local
|
|
710
713
|
if (head === null) return
|
|
711
714
|
if (!(await this._shouldReindex(head.key))) return
|
|
712
715
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
+
if (flushed && flushed.key && b4a.equals(flushed.key, local.key)) {
|
|
717
|
+
bee.move({ key: local.key, length: flushed.start + flushed.length })
|
|
718
|
+
return
|
|
716
719
|
}
|
|
717
720
|
|
|
721
|
+
await bee.reindex(async (change) => !(await this._shouldReindex(change.head.key)))
|
|
718
722
|
bee.move({ key: local.key, length: local.length })
|
|
719
723
|
}
|
|
720
724
|
|
|
@@ -1450,13 +1454,7 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
1450
1454
|
|
|
1451
1455
|
const changed = await this.system.flush(batch, this._workingBee)
|
|
1452
1456
|
|
|
1453
|
-
if (this._reindexed && (await this._isReindexed()))
|
|
1454
|
-
this._reindexed = false
|
|
1455
|
-
await this.local.setUserData(
|
|
1456
|
-
'autobee/head',
|
|
1457
|
-
encoding.encodeBootRecord(this.system.bootRecord())
|
|
1458
|
-
)
|
|
1459
|
-
}
|
|
1457
|
+
if (this._reindexed && (await this._isReindexed())) this._reindexed = false
|
|
1460
1458
|
|
|
1461
1459
|
if (this.system.promotions.changed) this._prefetchApprovals().catch(safetyCatch)
|
|
1462
1460
|
|