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

Commit 334873d

Browse files
authored
fix: align behaviour between go and js for content without paths (#3385)
Aligns behaviour between js and go when no path is present during an import - we now pass an empty string instead of `'unknown'`.
1 parent 633d870 commit 334873d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

packages/interface-ipfs-core/src/add-all.js

+22
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,28 @@ module.exports = (common, options) => {
171171
expect(root.cid.toString()).to.equal(fixtures.directory.cid)
172172
})
173173

174+
it('should receive progress path as empty string when adding content without paths', async function () {
175+
const content = (name) => fixtures.directory.files[name]
176+
const progressSizes = {}
177+
178+
const dirs = [
179+
content('pp.txt'),
180+
content('holmes.txt'),
181+
content('jungle.txt')
182+
]
183+
184+
const total = {
185+
'': dirs.reduce((acc, curr) => acc + curr.length, 0)
186+
}
187+
188+
const handler = (bytes, path) => {
189+
progressSizes[path] = bytes
190+
}
191+
192+
await drain(ipfs.addAll(dirs, { progress: handler }))
193+
expect(progressSizes).to.deep.equal(total)
194+
})
195+
174196
it('should receive file name from progress event', async () => {
175197
const receivedNames = []
176198
function handler (p, name) {

packages/ipfs-http-server/src/api/resources/files-regular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ exports.add = {
260260
multipart(request),
261261
async function * (source) {
262262
for await (const entry of source) {
263-
currentFileName = entry.name || 'unknown'
263+
currentFileName = entry.name || ''
264264

265265
if (entry.type === 'file') {
266266
filesParsed = true

0 commit comments

Comments
 (0)