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

Commit 21f49a3

Browse files
committed
fix: cat: test file existence *after* filtering. Should fix #1142
1 parent 5bfde87 commit 21f49a3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/core/components/files.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,15 @@ module.exports = function files (self) {
135135
pull(
136136
exporter(ipfsPath, self._ipldResolver),
137137
pull.collect((err, files) => {
138-
if (err) { d.end(err) }
138+
if (err) { return d.abort(err) }
139+
if (files && files.length > 1) {
140+
files = files.filter((file) => file.path === ipfsPath)
141+
}
139142
if (!files || !files.length) {
140143
return d.abort(new Error('No such file'))
141144
}
142145

143-
if (files.length > 1) {
144-
files = files.filter((file) => file.path === ipfsPath)
145-
}
146-
147146
const file = files[0]
148-
149147
const content = file.content
150148
if (!content && file.type === 'dir') {
151149
return d.abort(new Error('this dag node is a directory'))

0 commit comments

Comments
 (0)