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

WIP http cat#227

Merged
daviddias merged 3 commits into
masterfrom
cat/http
May 21, 2016
Merged

WIP http cat#227
daviddias merged 3 commits into
masterfrom
cat/http

Conversation

@nginnever

Copy link
Copy Markdown
Member

This is currently using the unixfs-engine event emitter but will be switching to a full duplex stream in the unixfs-engine.exporter soon

@jbenet jbenet added the status/in-progress In progress label May 17, 2016
@dignifiedquire

Copy link
Copy Markdown
Member

What I thought when I read ...cat.. in my notifications

giphy 3

@nginnever

Copy link
Copy Markdown
Member Author

Haha let's hope for none of this.

@daviddias

daviddias commented May 18, 2016

Copy link
Copy Markdown
Member

Awesomesauce @nginnever :)

Just to confirm, are you are top of converting the exporter in unixfs to a duplex stream?

@nginnever

Copy link
Copy Markdown
Member Author

@diasdavid yeah so this PR will update with the exporter.

Comment thread test/http-api-tests/test-files.js Outdated
})
})

it('returns a stream', (done) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer is not a stream

}).code(500)
}
stream.on('data', (data) => {
return reply(data.stream)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could lead to strange issues when multiple events are emitted from the stream.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be okay. The exporter stream in object mode only emits one data event per file. And cat can only request one file to my knowledge. If we allow at some point for cat to take multiple hashs and return multiple file objects then we could have a problem with this. Thoughts?

@hackergrrl hackergrrl May 21, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably will be okay, but I think @dignifiedquire's point was about approaching the mechanism defensively: just because today we can reason out that this should never happen doesn't mean future changes by future authors will always know+remember to hold this requirement. "It's a stream after all, and you can have many data events on streams.."

@nginnever

Copy link
Copy Markdown
Member Author

this will need PR to be merged

Comment thread src/cli/commands/files/cat.js Outdated
res.on('file', (data) => {
res.on('data', (data) => {
data.stream.pipe(process.stdout)
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this console.log should not be here and the if (res) is not necessary.

@daviddias daviddias merged commit 695a536 into master May 21, 2016
@daviddias daviddias deleted the cat/http branch May 21, 2016 10:04
@jbenet jbenet removed the status/in-progress In progress label May 21, 2016
@hackergrrl

Copy link
Copy Markdown
Contributor

I think @dignifiedquire had an unresolved line comment on this?

@dignifiedquire

Copy link
Copy Markdown
Member

@noffle it will be fine as soon as #253 is merged

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants