corestore 7.4.2 → 7.4.4
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 +6 -2
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const ReadyResource = require('ready-resource')
|
|
|
4
4
|
const sodium = require('sodium-universal')
|
|
5
5
|
const crypto = require('hypercore-crypto')
|
|
6
6
|
const ID = require('hypercore-id-encoding')
|
|
7
|
+
const { isAndroid } = require('which-runtime')
|
|
7
8
|
const { STORAGE_EMPTY } = require('hypercore-errors')
|
|
8
9
|
|
|
9
10
|
const auditStore = require('./lib/audit.js')
|
|
@@ -239,6 +240,8 @@ class Corestore extends ReadyResource {
|
|
|
239
240
|
this.primaryKey = this.root ? this.root.primaryKey : (opts.primaryKey || null)
|
|
240
241
|
this.ns = opts.namespace || DEFAULT_NAMESPACE
|
|
241
242
|
this.manifestVersion = opts.manifestVersion || 1
|
|
243
|
+
this.shouldSuspend = isAndroid ? !!opts.suspend : opts.suspend !== false
|
|
244
|
+
this.active = opts.active !== false
|
|
242
245
|
|
|
243
246
|
this.watchers = null
|
|
244
247
|
this.watchIndex = -1
|
|
@@ -289,6 +292,7 @@ class Corestore extends ReadyResource {
|
|
|
289
292
|
async suspend ({ log = noop } = {}) {
|
|
290
293
|
await log('Flushing db...')
|
|
291
294
|
await this.storage.db.flush()
|
|
295
|
+
if (!this.shouldSuspend) return
|
|
292
296
|
await log('Suspending db...')
|
|
293
297
|
await this.storage.db.suspend()
|
|
294
298
|
}
|
|
@@ -402,7 +406,7 @@ class Corestore extends ReadyResource {
|
|
|
402
406
|
muxer.cork()
|
|
403
407
|
|
|
404
408
|
for (const core of this.cores) {
|
|
405
|
-
if (!core.replicator.downloading || core.replicator.attached(muxer) || !core.opened) continue
|
|
409
|
+
if (!core.replicator.downloading || core.replicator.attached(muxer) || !core.opened || !this.active) continue
|
|
406
410
|
core.replicator.attachTo(muxer)
|
|
407
411
|
}
|
|
408
412
|
|
|
@@ -568,7 +572,7 @@ class Corestore extends ReadyResource {
|
|
|
568
572
|
}
|
|
569
573
|
|
|
570
574
|
core.replicator.ondownloading = () => {
|
|
571
|
-
this.streamTracker.attachAll(core)
|
|
575
|
+
if (this.active) this.streamTracker.attachAll(core)
|
|
572
576
|
}
|
|
573
577
|
|
|
574
578
|
this.cores.set(id, core)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.4",
|
|
4
4
|
"description": "A Hypercore factory that simplifies managing collections of cores.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"hypercore-errors": "^1.4.0",
|
|
15
15
|
"hypercore-id-encoding": "^1.3.0",
|
|
16
16
|
"ready-resource": "^1.1.1",
|
|
17
|
-
"sodium-universal": "^5.0.1"
|
|
17
|
+
"sodium-universal": "^5.0.1",
|
|
18
|
+
"which-runtime": "^1.2.1"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"brittle": "^3.7.0",
|