Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 17c2ec6

Browse files
committed
fix adding empty dirs
1 parent 78348b2 commit 17c2ec6

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"aegir": "^3.2.0",
3333
"chai": "^3.5.0",
3434
"gulp": "^3.9.1",
35-
"interface-ipfs-core": "^0.2.0",
35+
"interface-ipfs-core": "^0.2.1",
3636
"ipfsd-ctl": "^0.14.0",
3737
"pre-commit": "^1.1.2",
3838
"stream-equal": "^0.1.8",
@@ -93,4 +93,4 @@
9393
"url": "https://github.com/ipfs/js-ipfs-api/issues"
9494
},
9595
"homepage": "https://github.com/ipfs/js-ipfs-api"
96-
}
96+
}

src/get-files-stream.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function headers (file) {
1010
'Content-Disposition': `file; filename="${name}"`
1111
}
1212

13-
if (file.dir) {
13+
if (file.dir || !file.content) {
1414
header['Content-Type'] = 'application/x-directory'
1515
} else if (file.symlink) {
1616
header['Content-Type'] = 'application/symlink'
@@ -106,6 +106,11 @@ function getFilesStream (files, opts) {
106106
return loadPaths(opts, file)
107107
}
108108

109+
if (file.path && !file.content) {
110+
file.dir = true
111+
return file
112+
}
113+
109114
if (file.path && (file.content || file.dir)) {
110115
return file
111116
}

src/request-api.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ exports = module.exports = function getRequestAPI (config) {
144144
return p.then((res) => {
145145
return new Promise(function (resolve, reject) {
146146
transform(null, res, send, function (err, res) {
147-
if (err) reject(err)
148-
else resolve(res)
147+
if (err) {
148+
reject(err)
149+
} else {
150+
resolve(res)
151+
}
149152
})
150153
})
151154
})

0 commit comments

Comments
 (0)