From 209efe15cdd525be64cf4aa88f953e29088798e3 Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 15 Jul 2018 09:56:14 +0200 Subject: [PATCH 1/5] feat: compatible with go-ipfs 0.4.16 --- package.json | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 554bb0d00..446557421 100644 --- a/package.json +++ b/package.json @@ -71,25 +71,21 @@ "url": "https://github.com/ipfs/js-ipfs-api" }, "devDependencies": { - "aegir": "^14.0.0", + "aegir": "^15.0.0", "browser-process-platform": "~0.1.1", "chai": "^4.1.2", "cross-env": "^5.2.0", "dirty-chai": "^2.0.1", "eslint-plugin-react": "^7.10.0", - "go-ipfs-dep": "~0.4.15", + "go-ipfs-dep": "~0.4.16", "gulp": "^3.9.1", "interface-ipfs-core": "~0.72.1", - "ipfsd-ctl": "~0.37.5", + "ipfsd-ctl": "~0.38.0", "pull-stream": "^3.6.8", "socket.io": "^2.1.1", "socket.io-client": "^2.1.1", "stream-equal": "^1.1.1" }, - "pre-push": [ - "lint", - "test" - ], "keywords": [ "ipfs" ], From 3bf32d3cc2a596a1eff9324b00af0af9ec4ec56f Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 28 Jul 2018 15:09:51 +0200 Subject: [PATCH 2/5] chore: update to use go0.4.17 --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 446557421..9537db8c1 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "ipfs-block": "~0.7.1", "ipfs-unixfs": "~0.1.15", "ipld-dag-cbor": "~0.12.1", - "ipld-dag-pb": "~0.14.5", - "is-ipfs": "~0.3.2", + "ipld-dag-pb": "~0.14.6", + "is-ipfs": "~0.4.2", "is-pull-stream": "0.0.0", "is-stream": "^1.1.0", "libp2p-crypto": "~0.13.0", @@ -71,16 +71,16 @@ "url": "https://github.com/ipfs/js-ipfs-api" }, "devDependencies": { - "aegir": "^15.0.0", + "aegir": "^15.1.0", "browser-process-platform": "~0.1.1", "chai": "^4.1.2", "cross-env": "^5.2.0", "dirty-chai": "^2.0.1", "eslint-plugin-react": "^7.10.0", - "go-ipfs-dep": "~0.4.16", + "go-ipfs-dep": "~0.4.17", "gulp": "^3.9.1", "interface-ipfs-core": "~0.72.1", - "ipfsd-ctl": "~0.38.0", + "ipfsd-ctl": "~0.39.0", "pull-stream": "^3.6.8", "socket.io": "^2.1.1", "socket.io-client": "^2.1.1", From 297b13480a316b3b7178657762777b52f16a2a7d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 1 Aug 2018 20:46:25 +0100 Subject: [PATCH 3/5] feat: expose mfs files.read*Stream methods --- src/files/index.js | 2 ++ src/files/read-pull-stream.js | 26 ++++++++++++++++++++++++++ src/files/read-readable-stream.js | 26 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/files/read-pull-stream.js create mode 100644 src/files/read-readable-stream.js diff --git a/src/files/index.js b/src/files/index.js index f729f4305..6bcbd722b 100644 --- a/src/files/index.js +++ b/src/files/index.js @@ -24,6 +24,8 @@ module.exports = (arg) => { rm: require('./rm')(send), ls: require('./ls')(send), read: require('./read')(send), + readReadableStream: require('./read-readable-stream')(send), + readPullStream: require('./read-pull-stream')(send), write: require('./write')(send), mv: require('./mv')(send) } diff --git a/src/files/read-pull-stream.js b/src/files/read-pull-stream.js new file mode 100644 index 000000000..3e9ab8c3d --- /dev/null +++ b/src/files/read-pull-stream.js @@ -0,0 +1,26 @@ +'use strict' + +const toPull = require('stream-to-pull-stream') +const deferred = require('pull-defer') + +module.exports = (send) => { + return (args, opts) => { + opts = opts || {} + + const p = deferred.source() + + send({ + path: 'files/read', + args: args, + qs: opts + }, (err, stream) => { + if (err) { + return p.abort(err) + } + + p.resolve(toPull(stream)) + }) + + return p + } +} diff --git a/src/files/read-readable-stream.js b/src/files/read-readable-stream.js new file mode 100644 index 000000000..df8b92fbf --- /dev/null +++ b/src/files/read-readable-stream.js @@ -0,0 +1,26 @@ +'use strict' + +const Stream = require('readable-stream') +const pump = require('pump') + +module.exports = (send) => { + return (args, opts) => { + opts = opts || {} + + const pt = new Stream.PassThrough() + + send({ + path: 'files/read', + args: args, + qs: opts + }, (err, stream) => { + if (err) { + return pt.destroy(err) + } + + pump(stream, pt) + }) + + return pt + } +} From 9251ffc92a478c7654a1ecfe0996b5974f5c26fd Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 2 Aug 2018 07:52:16 -0700 Subject: [PATCH 4/5] chore: update interface-ipfs-core dependency 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 464a65ce5..4257eddca 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "eslint-plugin-react": "^7.10.0", "go-ipfs-dep": "~0.4.17", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.72.1", + "interface-ipfs-core": "~0.73.0", "ipfsd-ctl": "~0.39.0", "pull-stream": "^3.6.8", "socket.io": "^2.1.1", From 8fd216fdb1d02f55911371891ad46eff377121ba Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 2 Aug 2018 09:48:09 -0700 Subject: [PATCH 5/5] chore: increase timeouts for urlAdd tests License: MIT Signed-off-by: Alan Shaw --- test/util.spec.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/util.spec.js b/test/util.spec.js index 52ce9ebd7..f905911cc 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -114,7 +114,7 @@ describe('.util', () => { describe('.urlAdd', () => { it('http', function (done) { - this.timeout(20 * 1000) + this.timeout(40 * 1000) ipfs.util.addFromURL('http://example.com/', (err, result) => { expect(err).to.not.exist() @@ -124,7 +124,7 @@ describe('.util', () => { }) it('https', function (done) { - this.timeout(20 * 1000) + this.timeout(40 * 1000) ipfs.util.addFromURL('https://example.com/', (err, result) => { expect(err).to.not.exist() @@ -134,7 +134,7 @@ describe('.util', () => { }) it('http with redirection', function (done) { - this.timeout(20 * 1000) + this.timeout(40 * 1000) ipfs.util.addFromURL('http://covers.openlibrary.org/book/id/969165.jpg', (err, result) => { expect(err).to.not.exist() @@ -143,8 +143,8 @@ describe('.util', () => { }) }) - it('.urlAdd http with redirection', function (done) { - this.timeout(20 * 1000) + it('https with redirection', function (done) { + this.timeout(40 * 1000) ipfs.util.addFromURL('https://coverartarchive.org/release/6e2a1694-d8b9-466a-aa33-b1077b2333c1', (err, result) => { expect(err).to.not.exist() @@ -161,7 +161,7 @@ describe('.util', () => { }) it('with wrap-with-directory=true', function (done) { - this.timeout(20 * 1000) + this.timeout(40 * 1000) ipfs.util.addFromURL('http://ipfs.io/ipfs/QmWjppACLcFLQ2qL38unKQvJBhXH3RUtcGLPk7zmrTwV61/969165.jpg?foo=bar#buzz', { wrapWithDirectory: true @@ -175,7 +175,9 @@ describe('.util', () => { }) }) - it('with wrap-with-directory=true and URL-escaped file name', (done) => { + it('with wrap-with-directory=true and URL-escaped file name', function (done) { + this.timeout(40 * 1000) + // Sample URL contains URL-escaped ( ) and local diacritics ipfs.util.addFromURL('https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Doma%C5%BElice%2C_Jir%C3%A1skova_43_%289102%29.jpg/320px-Doma%C5%BElice%2C_Jir%C3%A1skova_43_%289102%29.jpg?foo=bar#buzz', { wrapWithDirectory: true @@ -189,7 +191,7 @@ describe('.util', () => { }) }) - it('with invalid url', function (done) { + it('with invalid url', (done) => { ipfs.util.addFromURL('http://invalid', (err, result) => { expect(err.code).to.equal('ENOTFOUND') expect(result).to.not.exist()