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

Upgrade the files branch (#323) to work with pull-streams #469

Merged
merged 8 commits into from
Sep 12, 2016
Merged

Conversation

dignifiedquire
Copy link
Member

@dignifiedquire dignifiedquire commented Sep 9, 2016

Some tests are still breaking, need to figure out why.

Needs:

TODO:

  • rebased add onto master
  • started using pull-streams in the file operations
  • made files get actually stream the file content, using streams + size args
  • fix tests:
    • http: files .cat streams a large file
    • http: files .get a large file
    • http: files .get directory

@dignifiedquire dignifiedquire added the status/in-progress In progress label Sep 9, 2016
@daviddias daviddias changed the title Make add branch work with pull streams Upgrade the files branch (#323) to work with pull-streams Sep 9, 2016
@dignifiedquire
Copy link
Member Author

Quick update: I managed to find the issue, it is a double read of the first chunk of the file, which happens due to a race condition inside pull-file. I am not certain how to best fix it though.

)
})

function handleError (err) {
Copy link
Member

Choose a reason for hiding this comment

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

Might not be a great idea to create this function every time a request happens. And in general, handleError should probably be somewhere global for the lib instead of specific to get.

@dignifiedquire
Copy link
Member Author

Fix for pull-file is up: pull-stream/pull-file#4

@daviddias
Copy link
Member

@dignifiedquire awesome! Shall we use the fork meanwhile?

@dignifiedquire
Copy link
Member Author

@diasdavid still working out some issues :/

@jbenet jbenet force-pushed the pull-add branch 2 times, most recently from aca631a to 72d35c0 Compare September 11, 2016 06:35
@daviddias
Copy link
Member

@jbenet fixed all the things :D (except pull-file, that still requires the PR to be merged)

@dignifiedquire
Copy link
Member Author

Whoo a wild @jbenet appears and fixes my code 😹

The other issue I fixed in ipfs/js-ipfs-repo#85

@daviddias
Copy link
Member

@dignifiedquire could you describe how we went from: 'pull-file has a race condition that emits the same chunk twice' to 'putting a lock that buffers the whole block is a fix'?

@@ -53,6 +53,7 @@ module.exports = function files (self) {
pull(
pull.values([hash]),
pull.asyncMap(self._dagS.get.bind(self._dagS)),
pull.take(1),
Copy link
Member

Choose a reason for hiding this comment

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

Can't these be replaced just with one call to dagService to get the DAGNode?

Copy link
Member Author

Choose a reason for hiding this comment

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

it could, but I like it this way :P

Copy link
Member

Choose a reason for hiding this comment

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

Why would we have something in 3 lines when we can just use one? It adds unnecessary complexity, memory overhead and superfluous ops.

Copy link
Member Author

Choose a reason for hiding this comment

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

no it doesn't add memory overhead, because the implementation of .get in the dagService is literally the same thing

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry, nvm what I'm doing here is stupid -.-

Copy link
Member

Choose a reason for hiding this comment

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

This is absurd. It's serious fancy abstraction creep. Careful

On Mon, Sep 12, 2016 at 10:53 AM Friedel Ziegelmayer <
notifications@github.com> wrote:

In src/core/ipfs/files.js
#469 (comment):

@@ -53,6 +53,7 @@ module.exports = function files (self) {
pull(
pull.values([hash]),
pull.asyncMap(self._dagS.get.bind(self._dagS)),

  •    pull.take(1),
    

sorry, nvm what I'm doing here is stupid -.-


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ipfs/js-ipfs/pull/469/files/06ee44fb061954f440d6c80df94609400dc8f12e#r78388308,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAIcoW2OqPNNILjFBhda_sNfyhs_gxARks5qpWd6gaJpZM4J5Uvl
.

@dignifiedquire
Copy link
Member Author

@dignifiedquire could you describe how we went from: 'pull-file has a race condition that emits the same chunk twice' to 'putting a lock that buffers the whole block is a fix'?

I filed a PR on pull-file as mentioned above, where @domenictarr was so nice to point out that calling the file stream twice without waiting for the previous cb to finish was a bug in the sink stream, not in pull-file, as pull-streams should always wait for the previous one to be finished. So I started to dig in and found that the reason why the source stream was called twice, was that we were not properly locking gets to the same keys in the blockstore (we were doing this before we transitioned to pull-streams, I simply forgot to put it back when doing the refactor).

}

const ipfs = request.server.app.ipfs
// TODO: make pull-multipart
Copy link
Member

Choose a reason for hiding this comment

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

Track this in a issue. @xicombd you probably would like to get that working, since you did the first multipart parser :)

Copy link
Member Author

Choose a reason for hiding this comment

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

@daviddias
Copy link
Member

@dignifiedquire interesting, so reading the same file twice causes an issue? That sounds weird.

Also, CR'ed this PR

@dignifiedquire
Copy link
Member Author

@dignifiedquire interesting, so reading the same file twice causes an issue? That sounds weird.

No reusing the same stream to read the file can cause issues

victorb and others added 2 commits September 12, 2016 13:02
Add tests for making sure .cat shows right output and fix that test by
using the right argument from cli. Ref: issue #476
@dignifiedquire
Copy link
Member Author

@diasdavid lets squash this into a single commit when merging please.

@daviddias
Copy link
Member

@dignifiedquire I've squashed and reworded, but not all into a single commit, because that loses the contributions from the different participants.

That being said, thank you everyone @nginnever @noffle @victorbjelkholm @dignifiedquire @jbenet that took part in this PR, js-ipfs is at least 40% more awesome and robust just for having all of these tests passing :D thank you! 👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏👏🎉👏

@victorb
Copy link
Member

victorb commented Sep 12, 2016

@jbenet
Copy link
Member

jbenet commented Sep 12, 2016

History is important too. Squash responsibly
On Mon, Sep 12, 2016 at 1:23 PM ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ notifications@github.com
wrote:

!()[http://i.giphy.com/l46CvRFB1GqPYAOis.gif]


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#469 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIcoeTW4S9j7j0h3ulqKNqoahecuuqJks5qpYqRgaJpZM4J5Uvl
.

@daviddias daviddias merged commit e0b69a8 into master Sep 12, 2016
@daviddias daviddias deleted the pull-add branch September 12, 2016 19:43
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.

6 participants