Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make urlSource compatible with new ipfs.add #53

Merged
merged 3 commits into from
Jan 15, 2021

Conversation

Gozala
Copy link
Contributor

@Gozala Gozala commented Jul 29, 2020

@Gozala Gozala requested a review from achingbrain July 29, 2020 19:46
@Gozala
Copy link
Contributor Author

Gozala commented Jul 29, 2020

@achingbrain I'm unable to push a branch to this repo, so I had to use my own fork for this pull request.

Comment on lines 12 to 16
const readURLContent = async function * (url, options) {
const http = new Http()
const response = await http.get(url, options)
yield * response.iterator()
}
Copy link
Member

Choose a reason for hiding this comment

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

i dont understand this change, why the wrapper ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hugomrdias so previously we had ipfs.add that could imported bunch of files or import a single one. Which later we have split into ipfs.add that imports a single file and takes single file like thing, and ipfs.addAll which imports multilpe files.

This change just makes return of urlSource compatible with ipfs.add as opposed to ipfs.addAll.

P.S.: ipfs.add implementation (but not the typings) will still accept many files, but plan is to make that not a case in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To answer your specific question, this does not add a wrapper but rather moves code doing the content fetching into content field which is expected to be AsyncIterable<Uint8Array>. effectively changing return type of this urlSource from AsyncIterable<{ path: string, content: AsyncIterable<Uint8Array> }> to { path: string, content: AsyncIterable<Uint8Array> } removing one layer of asynchronicity and making return be a single file as opposed to collection of files that always happen to contain one.

@achingbrain achingbrain merged commit 2b3ebbe into ipfs:master Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backwards compatibility of ipfs.add(urlSource(url))
3 participants