hypercore 11.0.40 → 11.0.42
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 +4 -0
- package/lib/core.js +2 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -295,6 +295,9 @@ class Hypercore extends EventEmitter {
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
this.emit('ready')
|
|
298
|
+
|
|
299
|
+
// if we are a weak session the core might have closed...
|
|
300
|
+
if (this.core.closing) this.close().catch(safetyCatch)
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
_removeSession () {
|
|
@@ -1081,6 +1084,7 @@ function initOnce (session, storage, key, opts) {
|
|
|
1081
1084
|
if (key === null) key = opts.key || null
|
|
1082
1085
|
|
|
1083
1086
|
session.core = new Core(Hypercore.defaultStorage(storage), {
|
|
1087
|
+
preopen: opts.preopen,
|
|
1084
1088
|
eagerUpgrade: true,
|
|
1085
1089
|
notDownloadingLinger: opts.notDownloadingLinger,
|
|
1086
1090
|
allowFork: opts.allowFork !== false,
|
package/lib/core.js
CHANGED
|
@@ -123,10 +123,11 @@ module.exports = class Core {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
this.opened = true
|
|
126
|
-
this.checkIfIdle()
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
async _tryOpen (opts) {
|
|
129
|
+
if (opts.preopen) await opts.preopen // just a hook to allow exclusive access here...
|
|
130
|
+
|
|
130
131
|
let storage = await this.db.resume(this.discoveryKey)
|
|
131
132
|
|
|
132
133
|
let overwrite = opts.overwrite === true
|