corestore 7.0.11 → 7.0.13

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.
Files changed (2) hide show
  1. package/lib/audit.js +7 -16
  2. package/package.json +1 -1
package/lib/audit.js CHANGED
@@ -1,23 +1,14 @@
1
- module.exports = async function audit (store, { dryRun = false } = {}) {
2
- const stats = { cores: 0, skipped: 0, rootless: 0, dropped: 0 }
3
-
1
+ module.exports = async function * audit (store, { dryRun = false } = {}) {
4
2
  for await (const { discoveryKey } of store.storage.createCoreStream()) {
5
- stats.cores++
6
-
7
- const core = await store.get({ discoveryKey, active: false })
3
+ const core = store.get({ discoveryKey, active: false })
8
4
  await core.ready()
9
5
 
10
- const audit = await core.core.audit({ dryRun })
6
+ yield { discoveryKey, key: core.key, audit: await core.core.audit({ dryRun }) }
11
7
 
12
- if (audit === null || audit.corrupt) {
13
- stats.rootless++
14
- continue
15
- }
16
-
17
- if (audit.droppedTreeNodes || audit.droppedBlocks || audit.droppedBits) {
18
- stats.dropped++
8
+ try {
9
+ await core.close()
10
+ } catch {
11
+ // ignore if failed, we are auditing...
19
12
  }
20
13
  }
21
-
22
- return stats
23
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corestore",
3
- "version": "7.0.11",
3
+ "version": "7.0.13",
4
4
  "description": "A Hypercore factory that simplifies managing collections of cores.",
5
5
  "main": "index.js",
6
6
  "files": [