hypercore-storage 2.5.4 → 2.5.6

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/index.js +3 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -429,6 +429,7 @@ class CorestoreStorage {
429
429
 
430
430
  this.bootstrap = storage !== null
431
431
  this.path = storage !== null ? storage : path.join(db.path, '..')
432
+ this.alwaysRecover = !!opts.alwaysRecover
432
433
  this.readOnly = !!opts.readOnly
433
434
  this.allowBackup = !!opts.allowBackup
434
435
  this.deviceFile = null
@@ -555,7 +556,7 @@ class CorestoreStorage {
555
556
  }
556
557
 
557
558
  _maybeRecoverLater(err) {
558
- if (!shouldRecover(err)) return
559
+ if (!shouldRecover(err) && !this.alwaysRecover) return
559
560
  fs.writeFileSync(path.join(this.db.path, 'RECOVERING'), '')
560
561
  for (const file of fs.readdirSync(this.db.path)) {
561
562
  if (file.endsWith('.log')) fs.unlinkSync(path.join(this.db.path, file))
@@ -1196,7 +1197,7 @@ async function fileExists(path) {
1196
1197
 
1197
1198
  function shouldRecover(err) {
1198
1199
  return err.message.toLowerCase().indexOf('sequence number is being set backwards') > -1
1199
-
1200
+ }
1200
1201
 
1201
1202
  function noop() {}
1202
1203
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",