corestore 7.0.12 → 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.
- package/lib/audit.js +2 -17
- package/package.json +1 -1
package/lib/audit.js
CHANGED
|
@@ -1,29 +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
3
|
const core = store.get({ discoveryKey, active: false })
|
|
8
4
|
await core.ready()
|
|
9
5
|
|
|
10
|
-
|
|
6
|
+
yield { discoveryKey, key: core.key, audit: await core.core.audit({ dryRun }) }
|
|
11
7
|
|
|
12
8
|
try {
|
|
13
9
|
await core.close()
|
|
14
10
|
} catch {
|
|
15
11
|
// ignore if failed, we are auditing...
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
if (audit === null || audit.corrupt) {
|
|
19
|
-
stats.rootless++
|
|
20
|
-
continue
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (audit.droppedTreeNodes || audit.droppedBlocks || audit.droppedBits) {
|
|
24
|
-
stats.dropped++
|
|
25
|
-
}
|
|
26
13
|
}
|
|
27
|
-
|
|
28
|
-
return stats
|
|
29
14
|
}
|