diff --git a/package.json b/package.json index 1b8f93c..046e4d9 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "homepage": "https://github.com/ipfs/js-ipfs-mfs#readme", "devDependencies": { - "aegir": "^15.0.0", + "aegir": "^15.2.0", "chai": "^4.1.2", "detect-node": "^2.0.3", "detect-webworker": "^1.0.0", @@ -54,7 +54,7 @@ "debug": "^3.1.0", "file-api": "~0.10.4", "filereader-stream": "^2.0.0", - "interface-datastore": "~0.4.2", + "interface-datastore": "~0.5.0", "ipfs-unixfs": "~0.1.15", "ipfs-unixfs-engine": "~0.32.1", "is-pull-stream": "~0.0.0", diff --git a/src/core/utils/with-mfs-root.js b/src/core/utils/with-mfs-root.js index 4235a32..24512ba 100644 --- a/src/core/utils/with-mfs-root.js +++ b/src/core/utils/with-mfs-root.js @@ -22,7 +22,8 @@ const withMfsRoot = (ipfs, callback) => { (cb) => { // Load the MFS root CID datastore.get(MFS_ROOT_KEY, (error, result) => { - if (error && error.notFound) { + // Once datastore-level releases its error.code addition, we can remove error.notFound logic + if (error && (error.notFound || error.code === 'ERR_NOT_FOUND')) { log('Creating new MFS root') return waterfall([ @@ -38,7 +39,8 @@ const withMfsRoot = (ipfs, callback) => { ], cb) } - cb(error, new CID(result)) + const cid = result ? new CID(result) : null + cb(error, cid) }) }, // Turn the Buffer into a CID