Comparing version 6.0.12 to 6.0.13
43
index.js
@@ -94,2 +94,3 @@ const b4a = require('b4a') | ||
this._draining = false | ||
this._advancing = null | ||
@@ -733,4 +734,5 @@ this._advanced = null | ||
// note: not parallel safe! | ||
async _getWriterByKey (key, len, seen, allowGC, system) { | ||
assert(this._draining === true || (this.opening && !this.opened)) | ||
let w = this.activeWriters.get(key) | ||
@@ -768,9 +770,21 @@ if (w !== null) { | ||
this._wakeup.unqueue(key, len) | ||
if (w !== this.localWriter) await w.close() | ||
return w | ||
if (w !== this.localWriter) { | ||
await w.close() | ||
return w | ||
} | ||
} | ||
const existing = this.activeWriters.get(key) | ||
if (existing) { | ||
await w.close() | ||
existing.seen(seen) | ||
return existing | ||
} | ||
this.activeWriters.add(w) | ||
this._checkWriters.push(w) | ||
assert(w.opened) | ||
assert(!w.closed) | ||
return w | ||
@@ -1058,3 +1072,3 @@ } | ||
for (const { key } of this._wakeup) { | ||
await this._getWriterByKey(key, -1, 0, true) | ||
await this._getWriterByKey(key, -1, 0, true, null) | ||
} | ||
@@ -1066,3 +1080,3 @@ | ||
for (const { key } of await this._getLocallyStoredHeads()) { | ||
await this._getWriterByKey(key, -1, 0, true) | ||
await this._getWriterByKey(key, -1, 0, true, null) | ||
} | ||
@@ -1074,3 +1088,3 @@ } | ||
const key = b4a.from(hex, 'hex') | ||
await this._getWriterByKey(key, -1, 0, true) | ||
await this._getWriterByKey(key, -1, 0, true, null) | ||
} | ||
@@ -1084,7 +1098,8 @@ | ||
// note: this might block due to network i/o | ||
if (this._needsWakeup === true || this._wakeupHints.size > 0) await this._drainWakeup() | ||
try { | ||
this._draining = true | ||
// note: this might block due to network i/o | ||
if (this._needsWakeup === true || this._wakeupHints.size > 0) await this._drainWakeup() | ||
await this._drain() | ||
this._draining = false | ||
} catch (err) { | ||
@@ -1513,3 +1528,3 @@ this._onError(err) | ||
const writer = (await this._getWriterByKey(key, -1, 0, false)) || this._makeWriter(key, 0, true) | ||
const writer = (await this._getWriterByKey(key, -1, 0, false, null)) || this._makeWriter(key, 0, true) | ||
await writer.ready() | ||
@@ -1734,4 +1749,4 @@ | ||
for (const { key } of this.system.indexers) { | ||
const indexer = await this._getWriterByKey(key) | ||
for (const { key, length } of this.system.indexers) { | ||
const indexer = await this._getWriterByKey(key, length, 0, false, null) | ||
indexers.push(indexer) | ||
@@ -1770,3 +1785,3 @@ } | ||
for (const { key, length } of this.system.indexers) { | ||
const w = await this._getWriterByKey(key, -1) | ||
const w = await this._getWriterByKey(key, length, 0, false, null) | ||
@@ -1854,3 +1869,3 @@ if (length > w.core.length) localUnflushed = true // local writer has nodes in mem | ||
for (const { key } of info.indexers) { | ||
p.push(await this._getWriterByKey(key)) | ||
p.push(await this._getWriterByKey(key, -1, 0, false, null)) | ||
} | ||
@@ -1857,0 +1872,0 @@ |
@@ -103,3 +103,3 @@ const b4a = require('b4a') | ||
return Promise.all(keys.map(({ key }) => this.base._getWriterByKey(key))) | ||
return Promise.all(keys.map(({ key }) => this.base._getWriterByKey(key, -1, 0, false, null))) | ||
} | ||
@@ -106,0 +106,0 @@ |
@@ -295,3 +295,3 @@ const Linearizer = require('./linearizer') | ||
const headWriter = await this.base._getWriterByKey(rawHead.key, -1, rawHead.length, true) | ||
const headWriter = await this.base._getWriterByKey(rawHead.key, -1, rawHead.length, true, null) | ||
@@ -298,0 +298,0 @@ if (headWriter !== this && (headWriter === null || headWriter.length < rawHead.length)) { |
{ | ||
"name": "autobase", | ||
"version": "6.0.12", | ||
"version": "6.0.13", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
167706
4481