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

Commit dcb453a

Browse files
author
Alan Shaw
authored
fix: cat deeply nested file (#1920)
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 <[email protected]>
1 parent 1478652 commit dcb453a

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"execa": "^1.0.0",
6969
"form-data": "^2.3.3",
7070
"hat": "0.0.3",
71-
"interface-ipfs-core": "~0.97.1",
71+
"interface-ipfs-core": "~0.98.1",
7272
"ipfsd-ctl": "~0.41.0",
7373
"libp2p-websocket-star": "~0.10.2",
7474
"ncp": "^2.0.0",

src/core/components/files-regular/cat-pull-stream.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ module.exports = function (self) {
1515

1616
ipfsPath = normalizePath(ipfsPath)
1717
const pathComponents = ipfsPath.split('/')
18-
const restPath = normalizePath(pathComponents.slice(1).join('/'))
19-
const filterFile = (file) => (restPath && file.path === restPath) || (file.path === ipfsPath)
18+
const fileNameOrHash = pathComponents[pathComponents.length - 1]
2019

2120
if (options.preload !== false) {
2221
self._preload(pathComponents[0])
@@ -26,7 +25,7 @@ module.exports = function (self) {
2625

2726
pull(
2827
exporter(ipfsPath, self._ipld, options),
29-
pull.filter(filterFile),
28+
pull.filter(file => file.path === fileNameOrHash),
3029
pull.take(1),
3130
pull.collect((err, files) => {
3231
if (err) {

0 commit comments

Comments
 (0)