From 62212c400e34cdf7d58481fc3a3e100c56bc2e62 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 12 Sep 2018 14:49:58 +0200 Subject: [PATCH 1/4] fix: update database not found error --- src/core/utils/with-mfs-root.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/utils/with-mfs-root.js b/src/core/utils/with-mfs-root.js index 4235a32..c5e32d8 100644 --- a/src/core/utils/with-mfs-root.js +++ b/src/core/utils/with-mfs-root.js @@ -22,7 +22,7 @@ const withMfsRoot = (ipfs, callback) => { (cb) => { // Load the MFS root CID datastore.get(MFS_ROOT_KEY, (error, result) => { - if (error && error.notFound) { + if (error && error.code === 'ERR_NOT_FOUND') { log('Creating new MFS root') return waterfall([ From 59bcf3c4f1f5f85765f6b9520b4e79360ae30760 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 12 Sep 2018 15:23:25 +0200 Subject: [PATCH 2/4] fix: avoid creating a cid with a null result --- src/core/utils/with-mfs-root.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/utils/with-mfs-root.js b/src/core/utils/with-mfs-root.js index c5e32d8..60ff6ef 100644 --- a/src/core/utils/with-mfs-root.js +++ b/src/core/utils/with-mfs-root.js @@ -38,7 +38,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 From 8fe47eb952aacb3b8d78367a881024361b8e45df Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Tue, 18 Sep 2018 11:03:06 +0200 Subject: [PATCH 3/4] chore: update deps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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", From 64ff6a1c00031f6f2414edf8ed675011ecf031d2 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 19 Sep 2018 22:01:57 +0200 Subject: [PATCH 4/4] fix: allow for graceful release with datastore-level --- src/core/utils/with-mfs-root.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/utils/with-mfs-root.js b/src/core/utils/with-mfs-root.js index 60ff6ef..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.code === 'ERR_NOT_FOUND') { + // 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([