hypercore-storage 2.0.4 → 2.1.1

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 +11 -19
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -441,14 +441,19 @@ class CorestoreStorage {
441
441
  this.version = 0
442
442
  this.migrating = null
443
443
 
444
- const preopen = this._openDeviceFile()
444
+ if ((this.bootstrap && !this.readOnly && !this.allowBackup) || this.wait) {
445
+ const corestoreFile = path.join(this.path, 'CORESTORE')
445
446
 
446
- this.preopen = preopen
447
- this.rocks =
448
- storage === null ? db : new RocksDB(path.join(this.path, 'db'), { ...opts, preopen })
449
- this.db = createColumnFamily(this.rocks, opts)
447
+ this.deviceFile = new DeviceFile(corestoreFile, {
448
+ wait: this.wait,
449
+ data: { id: this.id }
450
+ })
451
+ }
452
+
453
+ const dbPath = path.join(this.path, 'db')
450
454
 
451
- preopen.catch(noop) // awaited in rocks
455
+ this.rocks = storage === null ? db : new RocksDB(dbPath, { ...opts, lock: this.deviceFile })
456
+ this.db = createColumnFamily(this.rocks, opts)
452
457
  }
453
458
 
454
459
  get opened() {
@@ -459,19 +464,6 @@ class CorestoreStorage {
459
464
  return this.db.closed
460
465
  }
461
466
 
462
- async _openDeviceFile() {
463
- if ((this.bootstrap && !this.readOnly && !this.allowBackup) || this.wait) {
464
- const corestoreFile = path.join(this.path, 'CORESTORE')
465
-
466
- this.deviceFile = new DeviceFile(corestoreFile, {
467
- wait: this.wait,
468
- data: { id: this.id }
469
- })
470
-
471
- await this.deviceFile.ready()
472
- }
473
- }
474
-
475
467
  async ready() {
476
468
  if (this.version === 0) await this._migrateStore()
477
469
  return this.db.ready()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "2.0.4",
3
+ "version": "2.1.1",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",
@@ -33,13 +33,13 @@
33
33
  "bare-fs": "^4.0.1",
34
34
  "bare-path": "^3.0.0",
35
35
  "compact-encoding": "^2.16.0",
36
- "device-file": "^2.0.0",
36
+ "device-file": "^2.1.2",
37
37
  "flat-tree": "^1.12.1",
38
38
  "hypercore-crypto": "^3.4.2",
39
39
  "hyperschema": "^1.7.0",
40
40
  "index-encoder": "^3.3.2",
41
41
  "resolve-reject-promise": "^1.0.0",
42
- "rocksdb-native": "^3.1.1",
42
+ "rocksdb-native": "^3.11.0",
43
43
  "scope-lock": "^1.2.4",
44
44
  "streamx": "^2.21.1"
45
45
  },