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

Commit 561b053

Browse files
cli tests are passing
1 parent 0773706 commit 561b053

File tree

4 files changed

+31
-34
lines changed

4 files changed

+31
-34
lines changed

src/cli/commands/files/get.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ module.exports = {
103103
toPull.source(stream),
104104
pull.asyncMap(fileHandler(dir)),
105105
pull.onEnd((err) => {
106-
console.log('finished writing')
107106
if (err) {
108107
throw err
109108
}

src/http-api/resources/files.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const pull = require('pull-stream')
1010
const toPull = require('stream-to-pull-stream')
1111
const pushable = require('pull-pushable')
1212
const EOL = require('os').EOL
13-
const through = require('through2')
13+
const toStream = require('pull-stream-to-stream')
1414

1515
exports = module.exports
1616

@@ -87,33 +87,35 @@ exports.get = {
8787

8888
pull(
8989
stream,
90-
pull.asyncMap((file) => {
91-
const header = {name: file.path}
92-
if (!file.content) {
93-
header.type = 'directory'
94-
pack.entry(header)
95-
cb()
96-
} else {
97-
header.size = file.size
98-
const packStream = pack.entry(header, cb)
99-
if (!packStream) {
100-
// this happens if the request is aborted
101-
// we just skip things then
102-
log('other side hung up')
103-
return cb()
90+
pull.asyncMap((file, cb) => {
91+
const header = {name: file.path}
92+
if (!file.content) {
93+
header.type = 'directory'
94+
pack.entry(header)
95+
cb()
96+
} else {
97+
header.size = file.size
98+
const packStream = pack.entry(header, cb)
99+
if (!packStream) {
100+
// this happens if the request is aborted
101+
// we just skip things then
102+
log('other side hung up')
103+
return cb()
104+
}
105+
toStream.source(file.content).pipe(packStream)
104106
}
105-
file.content.pipe(packStream)
106-
}
107-
}), (err) => {
108-
if (err) {
109-
log.error(err)
110-
pack.emit('error', err)
111-
pack.destroy()
112-
return
113-
}
114-
console.log('finalizinng')
115-
pack.finalize()
116-
})
107+
}),
108+
pull.onEnd((err) => {
109+
if (err) {
110+
log.error(err)
111+
pack.emit('error', err)
112+
pack.destroy()
113+
return
114+
}
115+
116+
pack.finalize()
117+
})
118+
)
117119

118120
// the reply must read the tar stream,
119121
// to pull values through

test/cli/test-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const fs = require('fs')
88
const path = require('path')
99
const describeOnlineAndOffline = require('../utils/on-and-off')
1010

11-
describe.only('files', () => {
11+
describe('files', () => {
1212
const env = _.clone(process.env)
1313
env.IPFS_PATH = repoPath
1414
const ipfs = require('../utils/ipfs')(env)

test/utils/ipfs.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ module.exports = (env) => function ipfs () {
1010
env: env,
1111
timeout: 60 * 1000
1212
}).then((res) => {
13-
expect(res).to.have.property('stderr', '')
14-
15-
if (res.error) {
16-
throw res.error
17-
}
13+
expect(res.stderr).to.be.eql('')
1814

1915
return res.stdout
2016
})

0 commit comments

Comments
 (0)