Skip to content

Commit

Permalink
fix: upgrade datastores for node 10 (#168)
Browse files Browse the repository at this point in the history
* fix: upgrade datastores for node 10

move the responsibility of levelup browser support to datastore-level

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>

* chore: add node 10 to jenkins

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>

chore: use 10.0 instead of 10.1

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>

* chore: update jenkins overrides

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>

* fix: keep initialized errors separate from unknowns

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>

* refactor: move error code to an exported constant

* chore: update deps

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>

* chore: update deps
  • Loading branch information
Jacob Heun authored and daviddias committed May 29, 2018
1 parent cdc5f4a commit bd8a930
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
javascript()
javascript(['nodejs_versions': ['8.11.1','9.2.0','10.0.0']])
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"browser": {
"rimraf": false,
"datastore-fs": "datastore-level",
"leveldown": "level-js",
"./src/lock.js": "./src/lock-memory.js",
"./src/default-options.js": "./src/default-options-browser.js"
},
Expand Down Expand Up @@ -60,14 +59,12 @@
"big.js": "^5.0.3",
"cids": "~0.5.3",
"datastore-core": "~0.4.0",
"datastore-fs": "~0.4.2",
"datastore-level": "~0.7.0",
"datastore-fs": "~0.5.0",
"datastore-level": "~0.8.0",
"debug": "^3.1.0",
"interface-datastore": "~0.4.2",
"ipfs-block": "~0.7.1",
"level-js": "timkuijsten/level.js#idbunwrapper",
"leveldown": "^1.7.2",
"lock-me": "^1.0.3",
"lock-me": "^1.0.4",
"lodash.get": "^4.4.2",
"lodash.has": "^4.5.2",
"lodash.set": "^4.3.2",
Expand Down
10 changes: 2 additions & 8 deletions src/default-options-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@ module.exports = {
},
storageBackendOptions: {
root: {
db: require('level-js'),
extension: ''
},
blocks: {
sharding: false,
db: require('level-js')
sharding: false
},
keys: {
sharding: false,
db: require('level-js')
},
datastore: {
db: require('level-js')
sharding: false
}
}
}
3 changes: 3 additions & 0 deletions src/errors/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict'

exports.ERR_REPO_NOT_INITIALIZED = 'ERR_REPO_NOT_INITIALIZED'
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const config = require('./config')
const apiAddr = require('./api-addr')
const blockstore = require('./blockstore')
const defaultOptions = require('./default-options')
const ERRORS = require('./errors')

const log = debug('repo')

Expand Down Expand Up @@ -212,14 +213,14 @@ class IpfsRepo {
},
(err, res) => {
log('init', err, res)
if (err) {
if (err && !res.config) {
return callback(Object.assign(new Error('repo is not initialized yet'),
{
code: 'ERR_REPO_NOT_INITIALIZED',
code: ERRORS.ERR_REPO_NOT_INITIALIZED,
path: this.path
}))
}
callback()
callback(err)
}
)
}
Expand Down Expand Up @@ -355,7 +356,9 @@ function ignoringAlreadyOpened (cb) {
}

function ignoringNotFound (cb) {
return ignoringIf((err) => err.message.startsWith('ENOENT'), cb)
return ignoringIf((err) => {
return err && (err.code === ERRORS.ERR_REPO_NOT_INITIALIZED || err.message.startsWith('ENOENT'))
}, cb)
}

function buildOptions (_options) {
Expand Down
6 changes: 0 additions & 6 deletions test/options-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,9 @@ function expectedRepoOptions () {
}

if (process.browser) {
options.storageBackendOptions.root.db = require('leveldown')
options.storageBackendOptions.keys.db = require('leveldown')
options.storageBackendOptions.keys.sharding = false
options.storageBackendOptions.blocks.db = require('leveldown')
delete options.storageBackendOptions.blocks.extension
options.storageBackendOptions.blocks.sharding = false
options.storageBackendOptions.datastore = {
db: require('leveldown')
}
}
return options
}

0 comments on commit bd8a930

Please sign in to comment.