hypercore 11.0.15 → 11.0.17
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 +9 -2
- package/lib/core.js +4 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -288,7 +288,6 @@ class Hypercore extends EventEmitter {
|
|
|
288
288
|
try {
|
|
289
289
|
await this._openSession(opts)
|
|
290
290
|
} catch (err) {
|
|
291
|
-
if (this.closing) return
|
|
292
291
|
if (this.core.autoClose && this.core.hasSession() === false) await this.core.close()
|
|
293
292
|
|
|
294
293
|
if (this.exclusive) this.core.unlockExclusive()
|
|
@@ -298,6 +297,7 @@ class Hypercore extends EventEmitter {
|
|
|
298
297
|
|
|
299
298
|
if (this.state !== null) this.state.removeSession(this)
|
|
300
299
|
|
|
300
|
+
this.closed = true
|
|
301
301
|
this.emit('close', this.core.hasSession() === false)
|
|
302
302
|
throw err
|
|
303
303
|
}
|
|
@@ -428,7 +428,14 @@ class Hypercore extends EventEmitter {
|
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
async _close (error) {
|
|
431
|
-
if (this.opened === false)
|
|
431
|
+
if (this.opened === false) {
|
|
432
|
+
try {
|
|
433
|
+
await this.opening
|
|
434
|
+
} catch (err) {
|
|
435
|
+
if (!this.closed) throw err
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
432
439
|
if (this.closed === true) return
|
|
433
440
|
|
|
434
441
|
this.core.removeMonitor(this)
|
package/lib/core.js
CHANGED
|
@@ -150,6 +150,10 @@ module.exports = class Core {
|
|
|
150
150
|
overwrite = true
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
if (!header && (opts.discoveryKey && !(opts.key || opts.manifest))) {
|
|
154
|
+
throw STORAGE_EMPTY('No Hypercore is stored here')
|
|
155
|
+
}
|
|
156
|
+
|
|
153
157
|
if (!header || overwrite) {
|
|
154
158
|
if (!createIfMissing) {
|
|
155
159
|
throw STORAGE_EMPTY('No Hypercore is stored here')
|