Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Commit

Permalink
fix(ipfs): prevent stringify on stream
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshyx committed Oct 17, 2016
1 parent 92d961a commit 8dfc9b5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/IpfsApiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export class IpfsApiHelper {
* @param isProtobuf
* @returns {any}
*/
add(data: Object | Buffer, isProtobuf = false) {
add(data: any, isProtobuf = false) {
let dataBuffer: Buffer;
if (Buffer.isBuffer(data)) {
if (Buffer.isBuffer(data) || isProtobuf) {
dataBuffer = data;
} else {
dataBuffer = toDataBuffer(data);
Expand Down
4 changes: 3 additions & 1 deletion src/IpfsConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export class IpfsConnector extends EventEmitter {
return this.emit(events.SERVICE_STARTED);
}
if (data.includes('API server')) {
this.options.apiAddress = data.toString().trim().split(' ').pop();
setTimeout(() => {
this.options.apiAddress = data.toString().trim().split(' ').pop();
}, 1);
}
});
this._callbacks.set('ipfs.exit', (code: number, signal: string) => {
Expand Down
2 changes: 2 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('IpfsConnector', function () {
it('should set a different logger', function () {
instance.setLogger(logger);
expect(instance.logger).to.deep.equal(logger);
instance.setLogger(console);
});
it('should emit error when specifying bad ipfs-api address', function (done) {
const memAddr = instance.options.apiAddress;
Expand Down Expand Up @@ -110,6 +111,7 @@ describe('IpfsConnector', function () {
});
instance.setPorts({ api: 5041, swarm: 4041, gateway: 8040 }, true)
.then((ports) => {
console.log(instance.options);
expect(instance.options.apiAddress).to.equal('/ip4/127.0.0.1/tcp/5041');
expect(ports).to.exist;
})
Expand Down

0 comments on commit 8dfc9b5

Please sign in to comment.