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

fix(files.add): directory with odd name #1155

Merged
merged 1 commit into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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