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

Commit

Permalink
fix(files.add): directory with odd name (#1155)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider authored and daviddias committed Dec 18, 2017
1 parent 279af78 commit 058c674
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/cli/commands/files/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,20 @@ module.exports = {
}
const ipfs = argv.ipfs

let list = []
let list
waterfall([
(next) => glob(path.join(inPath, '/**/*'), next),
(next) => {
if (fs.statSync(inPath).isDirectory()) {
return glob('**/*', { cwd: inPath }, next)
}
next(null, [])
},
(globResult, next) => {
list = globResult.length === 0 ? [inPath] : globResult

if (globResult.length === 0) {
list = [inPath]
} else {
list = globResult.map((f) => inPath + '/' + f)
}
getTotalBytes(inPath, argv.recursive, next)
},
(totalBytes, next) => {
Expand Down
14 changes: 14 additions & 0 deletions test/cli/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ describe('files', () => runOnAndOff((thing) => {
})
})

it('add directory with odd name', function () {
this.timeout(30 * 1000)
const expected = [
'added QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o odd-name-[v0]/odd name [v1]/hello',
'added QmYRMUVULBfj7WrdPESnwnyZmtayN6Sdrwh1nKcQ9QgQeZ odd-name-[v0]/odd name [v1]',
'added QmXJGoo27bg7ExNAtr9vRcivxDwcfHtkxatGno9HrUdR16 odd-name-[v0]'
]

return ipfs('files add -r test/fixtures/odd-name-[v0]')
.then((out) => {
expect(out).to.eql(expected.join('\n') + '\n')
})
})

it('add and wrap with a directory', function () {
this.timeout(30 * 1000)

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/odd-name-[v0]/odd name [v1]/hello
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world

0 comments on commit 058c674

Please sign in to comment.