Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: cat deeply nested file (#1920)
Browse files Browse the repository at this point in the history
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 <alan.shaw@protocol.ai>
  • Loading branch information
Alan Shaw authored Mar 14, 2019
1 parent 1478652 commit dcb453a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "~0.98.1",
"ipfsd-ctl": "~0.41.0",
"libp2p-websocket-star": "~0.10.2",
"ncp": "^2.0.0",
Expand Down
5 changes: 2 additions & 3 deletions src/core/components/files-regular/cat-pull-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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) {
Expand Down

0 comments on commit dcb453a

Please sign in to comment.