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

Commit

Permalink
fix: align behaviour between go and js for content without paths (#3385)
Browse files Browse the repository at this point in the history
Aligns behaviour between js and go when no path is present during an import
- we now pass an empty string instead of `'unknown'`.
  • Loading branch information
achingbrain committed Nov 12, 2020
1 parent 633d870 commit 334873d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/interface-ipfs-core/src/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,28 @@ module.exports = (common, options) => {
expect(root.cid.toString()).to.equal(fixtures.directory.cid)
})

it('should receive progress path as empty string when adding content without paths', async function () {
const content = (name) => fixtures.directory.files[name]
const progressSizes = {}

const dirs = [
content('pp.txt'),
content('holmes.txt'),
content('jungle.txt')
]

const total = {
'': dirs.reduce((acc, curr) => acc + curr.length, 0)
}

const handler = (bytes, path) => {
progressSizes[path] = bytes
}

await drain(ipfs.addAll(dirs, { progress: handler }))
expect(progressSizes).to.deep.equal(total)
})

it('should receive file name from progress event', async () => {
const receivedNames = []
function handler (p, name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ exports.add = {
multipart(request),
async function * (source) {
for await (const entry of source) {
currentFileName = entry.name || 'unknown'
currentFileName = entry.name || ''

if (entry.type === 'file') {
filesParsed = true
Expand Down

0 comments on commit 334873d

Please sign in to comment.