From f7d8f6302cb1e11d9ea00a09392f22a0e5840ba3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 23 Jan 2019 12:40:00 -0800 Subject: [PATCH 1/5] fix: add support for resolving to the middle of an IPLD block see: https://github.com/ipfs/interface-ipfs-core/pull/385 --- src/core/components/resolve.js | 1 + test/core/resolve.spec.js | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/core/resolve.spec.js diff --git a/src/core/components/resolve.js b/src/core/components/resolve.js index 1ca80e8249..a54dc3d019 100644 --- a/src/core/components/resolve.js +++ b/src/core/components/resolve.js @@ -44,6 +44,7 @@ module.exports = (self) => { // Resolve the given CID + path to a CID. function resolve (cid, path, callback) { let value, remainderPath + doUntil( (cb) => { self.block.get(cid, (err, block) => { diff --git a/test/core/resolve.spec.js b/test/core/resolve.spec.js new file mode 100644 index 0000000000..7950e0daa9 --- /dev/null +++ b/test/core/resolve.spec.js @@ -0,0 +1,57 @@ +/* eslint max-nested-callbacks: ["error", 8] */ +/* eslint-env mocha */ +'use strict' + +const chai = require('chai') +const dirtyChai = require('dirty-chai') +const expect = chai.expect +chai.use(dirtyChai) + +const IPFSFactory = require('ipfsd-ctl') +const IPFS = require('../../src/core') + +describe('resolve', () => { + let ipfsd, ipfs + + before(function (done) { + this.timeout(20 * 1000) + + const factory = IPFSFactory.create({ type: 'proc' }) + + factory.spawn({ + exec: IPFS, + initOptions: { bits: 512 }, + config: { Bootstrap: [] } + }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = _ipfsd.api + done() + }) + }) + + after((done) => { + if (ipfsd) { + ipfsd.stop(done) + } else { + done() + } + }) + + it('should resolve an IPFS path non-link', (done) => { + const content = { path: { to: { file: 'foobar' } } } + const options = { format: 'dag-cbor', hashAlg: 'sha2-256' } + + ipfs.dag.put(content, options, (err, cid) => { + expect(err).to.not.exist() + + // FIXME: This should be /ipld/... but that's not supported yet. + const path = `/ipfs/${cid.toBaseEncodedString()}/path/to/file` + ipfs.resolve(path, (err, resolved) => { + expect(err).to.not.exist() + expect(resolved).to.equal(path) + done() + }) + }) + }) +}) From ec1442cc9af8d47cafa94fe0df255c969609ce6a Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 Feb 2019 13:33:46 +0000 Subject: [PATCH 2/5] fix: resolve when value is a CID or a {'/': 'string cid'} License: MIT Signed-off-by: Alan Shaw --- test/core/resolve.spec.js | 57 --------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 test/core/resolve.spec.js diff --git a/test/core/resolve.spec.js b/test/core/resolve.spec.js deleted file mode 100644 index 7950e0daa9..0000000000 --- a/test/core/resolve.spec.js +++ /dev/null @@ -1,57 +0,0 @@ -/* eslint max-nested-callbacks: ["error", 8] */ -/* eslint-env mocha */ -'use strict' - -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - -const IPFSFactory = require('ipfsd-ctl') -const IPFS = require('../../src/core') - -describe('resolve', () => { - let ipfsd, ipfs - - before(function (done) { - this.timeout(20 * 1000) - - const factory = IPFSFactory.create({ type: 'proc' }) - - factory.spawn({ - exec: IPFS, - initOptions: { bits: 512 }, - config: { Bootstrap: [] } - }, (err, _ipfsd) => { - expect(err).to.not.exist() - ipfsd = _ipfsd - ipfs = _ipfsd.api - done() - }) - }) - - after((done) => { - if (ipfsd) { - ipfsd.stop(done) - } else { - done() - } - }) - - it('should resolve an IPFS path non-link', (done) => { - const content = { path: { to: { file: 'foobar' } } } - const options = { format: 'dag-cbor', hashAlg: 'sha2-256' } - - ipfs.dag.put(content, options, (err, cid) => { - expect(err).to.not.exist() - - // FIXME: This should be /ipld/... but that's not supported yet. - const path = `/ipfs/${cid.toBaseEncodedString()}/path/to/file` - ipfs.resolve(path, (err, resolved) => { - expect(err).to.not.exist() - expect(resolved).to.equal(path) - done() - }) - }) - }) -}) From fff5c5d7137f38f5ddda2342a6dbca4ba948f47b Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 Feb 2019 16:07:47 +0000 Subject: [PATCH 3/5] fix: temporary fix for pin.rm EPERM rename issue License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a64d1b08c6..ada0b75249 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "execa": "^1.0.0", "form-data": "^2.3.3", "hat": "0.0.3", - "interface-ipfs-core": "~0.97.0", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#fix/populate-series", "ipfsd-ctl": "~0.41.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0", From 2690988c72cdadfcff0725e691db8b12870cbc04 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 Feb 2019 20:09:32 +0000 Subject: [PATCH 4/5] chore: update interface-ipfs-core License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ada0b75249..6ca11e0338 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "execa": "^1.0.0", "form-data": "^2.3.3", "hat": "0.0.3", - "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#fix/populate-series", + "interface-ipfs-core": "~0.97.1", "ipfsd-ctl": "~0.41.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0", From 5f5fa7888cdf1f8a1fb53d1caf712ebc9b8d9230 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 Feb 2019 20:11:10 +0000 Subject: [PATCH 5/5] chore: remove additional newline License: MIT Signed-off-by: Alan Shaw --- src/core/components/resolve.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/components/resolve.js b/src/core/components/resolve.js index a54dc3d019..1ca80e8249 100644 --- a/src/core/components/resolve.js +++ b/src/core/components/resolve.js @@ -44,7 +44,6 @@ module.exports = (self) => { // Resolve the given CID + path to a CID. function resolve (cid, path, callback) { let value, remainderPath - doUntil( (cb) => { self.block.get(cid, (err, block) => {