From 3745347912409e834e541e416a9c7fb76202bc7f Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 12 Mar 2019 13:29:34 +0000 Subject: [PATCH 1/2] fix: cat deeply nested file The exporter was exporting the file, but the filter was filtering it out because the exported path includes only `file.txt` but the filter was expecting `path/file.txt`. So when you cat `/ipfs/QmHash/file.txt` it worked, but when you cat `/ipfs/QmHash/path/file.txt` it did not. License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- src/core/components/files-regular/cat-pull-stream.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 737ef9cbad..75e3592da8 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.1", + "interface-ipfs-core": "ipfs/interface-js-ipfs-core#test/add-test-for-deeply-nested-file", "ipfsd-ctl": "~0.41.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0", diff --git a/src/core/components/files-regular/cat-pull-stream.js b/src/core/components/files-regular/cat-pull-stream.js index 41c126e8d3..ceecff97e8 100644 --- a/src/core/components/files-regular/cat-pull-stream.js +++ b/src/core/components/files-regular/cat-pull-stream.js @@ -15,8 +15,7 @@ module.exports = function (self) { ipfsPath = normalizePath(ipfsPath) const pathComponents = ipfsPath.split('/') - const restPath = normalizePath(pathComponents.slice(1).join('/')) - const filterFile = (file) => (restPath && file.path === restPath) || (file.path === ipfsPath) + const fileNameOrHash = pathComponents[pathComponents.length - 1] if (options.preload !== false) { self._preload(pathComponents[0]) @@ -26,7 +25,7 @@ module.exports = function (self) { pull( exporter(ipfsPath, self._ipld, options), - pull.filter(filterFile), + pull.filter(file => file.path === fileNameOrHash), pull.take(1), pull.collect((err, files) => { if (err) { From d3489a8aedd36ecd209893c02cce284078d99882 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 13 Mar 2019 14:02:12 +0000 Subject: [PATCH 2/2] chore: update interface-ipfs-core dep --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75e3592da8..b758316f34 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": "ipfs/interface-js-ipfs-core#test/add-test-for-deeply-nested-file", + "interface-ipfs-core": "~0.98.1", "ipfsd-ctl": "~0.41.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0",