From 4536160b71a48a2bd6c8dce304ce70b50b1c04e5 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 26 Mar 2018 18:36:11 +0100 Subject: [PATCH 1/5] docs: You can't ipfs.add a path (#245) * You can't ipfs.add a path Fixes https://github.com/ipfs/js-ipfs-api/issues/722 * Remove URL from files.add --- SPEC/FILES.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/SPEC/FILES.md b/SPEC/FILES.md index 2220ecd10..78644c376 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -16,8 +16,6 @@ Where `data` may be: - a [`Buffer instance`][b] - a [`Readable Stream`][rs] - a [`Pull Stream`][ps] -- a Path (caveat: will only work in Node.js) -- a URL - an array of objects, each of the form: ```JavaScript { From 03eec9e5dd761a1da653b99f4608f22cf2d194e9 Mon Sep 17 00:00:00 2001 From: Michael Garvin Date: Fri, 30 Mar 2018 15:45:33 -0700 Subject: [PATCH 2/5] feat: add wrapWithDirectory to files.add et al --- SPEC/FILES.md | 3 +++ js/src/files.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/SPEC/FILES.md b/SPEC/FILES.md index 78644c376..810f117d2 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -31,6 +31,7 @@ If no `content` is passed, then the path is treated as an empty directory - progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs. - recursive (boolean): for when a Path is passed, this option can be enabled to add recursively all the files. - hashAlg || hash (string): multihash hashing algorithm to use +- wrapWithDirectory (boolean): adds a wrapping node around the content `callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of: @@ -83,6 +84,7 @@ Returns a Readable Stream of class Duplex, where objects can be written of the f - cid-version (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, including it's version) - progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs. - hashAlg || hash (string): multihash hashing algorithm to use +- wrapWithDirectory (boolean): adds a wrapping node around the content **Example:** @@ -131,6 +133,7 @@ Returns a Pull Stream, where objects can be written of the forms - cid-version (integer, default 0): the CID version to use when storing the data (storage keys are based on the CID, including it's version) - progress (function): a function that will be called with the byte length of chunks as a file is added to ipfs. - hashAlg || hash (string): multihash hashing algorithm to use +- wrapWithDirectory (boolean): adds a wrapping node around the content **Example:** diff --git a/js/src/files.js b/js/src/files.js index 033372ba0..acc2d11c0 100644 --- a/js/src/files.js +++ b/js/src/files.js @@ -31,10 +31,16 @@ module.exports = (common) => { return loadFixture(path, 'interface-ipfs-core') } + const wrapDirectory = { + path: 'wrapper/', + cid: 'QmbzKtHxQXJnWG9VR66TscUfcoK3CV4nceRsCdyAEsEj9A' + } + const smallFile = { cid: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', data: fixture('js/test/fixtures/testfile.txt') } + const bigFile = { cid: 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq', data: fixture('js/test/fixtures/15mb.random') @@ -257,6 +263,19 @@ module.exports = (common) => { }) }) + it('wrapWithDirectory', (done) => { + return ipfs.files.add({ path: 'testfile.txt', content: smallFile.data }, { wrapWithDirectory: true }, (err, filesAdded) => { + expect(err).to.not.exist(); + expect(filesAdded).to.have.length(2); + const file = filesAdded[0]; + const wrapped = filesAdded[1] + expect(file.hash).to.equal(smallFile.cid) + expect(file.path).to.equal('testfile.txt') + expect(wrapped.path).to.equal(wrapDirectory.cid); + done(); + }); + }); + it('Promise test', () => { return ipfs.files.add(smallFile.data) .then((filesAdded) => { From cbe7e6855ac22b79d04e26ec40fc788eb0d942e7 Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 3 Apr 2018 07:13:17 +0100 Subject: [PATCH 3/5] chore: update deps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 166589052..973732c84 100644 --- a/package.json +++ b/package.json @@ -44,11 +44,11 @@ "ipfs-block": "~0.6.1", "ipld-dag-cbor": "~0.12.0", "ipld-dag-pb": "~0.13.1", - "multiaddr": "^3.0.2", + "multiaddr": "^3.1.0", "multihashes": "~0.4.13", "multihashing-async": "~0.4.8", "peer-id": "~0.10.6", - "pull-stream": "^3.6.2" + "pull-stream": "^3.6.7" }, "devDependencies": {}, "contributors": [ From 42826ad70f0212b0570367c557ee65fc4995f5e1 Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 3 Apr 2018 07:13:31 +0100 Subject: [PATCH 4/5] chore: update contributors --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 973732c84..d8a82f6f3 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,10 @@ "Kevin Simper ", "Marius Darila ", "Matt Zumwalt ", + "Michael Garvin ", "Michael Muré ", "Nicolás Santángelo ", + "Oli Evans ", "Pedro Teixeira ", "Richard Littauer ", "Richard Schneider ", From 0e1ad8d3c69449071142d5655c8177c4534a975a Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 3 Apr 2018 07:13:31 +0100 Subject: [PATCH 5/5] chore: release version v0.59.0 --- CHANGELOG.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f06cfd615..5ae1fcd93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +# [0.59.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.58.0...v0.59.0) (2018-04-03) + + +### Features + +* add wrapWithDirectory to files.add et al ([03eec9e](https://github.com/ipfs/interface-ipfs-core/commit/03eec9e)) + + + # [0.58.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.57.0...v0.58.0) (2018-03-22) diff --git a/package.json b/package.json index d8a82f6f3..d7124f8e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interface-ipfs-core", - "version": "0.58.0", + "version": "0.59.0", "description": "A test suite and interface you can use to implement a IPFS core interface.", "main": "js/src/index.js", "scripts": {