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

Commit 8833bb4

Browse files
committed
refactoring
1 parent d78946a commit 8833bb4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ module.exports = function (self) {
2828

2929
pull(
3030
exporter(cid, self._ipld, options),
31+
pull.filter(link => {
32+
return link.path === ipfsPath.substring(0, link.path.length)
33+
}),
3134
pull.filter(link => {
3235
// save the closest matched path so we can show in error if no file was found
33-
if ((link.path === ipfsPath.substring(0, link.path.length) &&
34-
link.depth > closestMatchedLink.depth) || !closestMatchedLink) {
36+
if (!closestMatchedLink || link.depth > closestMatchedLink.depth) {
3537
closestMatchedLink = link
3638
}
3739

@@ -44,8 +46,8 @@ module.exports = function (self) {
4446
}
4547

4648
if (!files.length) {
47-
const fileNotFound = ipfsPath.substring(closestMatchedLink.path.length + 1)
48-
return d.abort(new Error(`no file named "${fileNotFound}" under ${closestMatchedLink.path}`))
49+
const linkNotFound = ipfsPath.substring(closestMatchedLink.path.length + 1)
50+
return d.abort(new Error(`no file named "${linkNotFound}" under ${closestMatchedLink.path}`))
4951
}
5052

5153
const file = files[0]

0 commit comments

Comments
 (0)