Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

FIX: Reconstruct multiple fragments #41

Merged
merged 2 commits into from
Nov 24, 2017
Merged

Conversation

lamphamsy
Copy link
Contributor

Fragments reconstruction runs in parallel. Hence recovered fragments
could be not in right order.

Fix sort function

@lamphamsy lamphamsy changed the title Reconstruct multiple fragments FIX: Reconstruct multiple fragments Nov 21, 2016
node-eclib.js Outdated
this.reconstructFragment(availFragments, id,
function recon(err, fragment) {
if (err) {
callback(err);
return callback(err);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You cannot return early from a forEach and using this would call the callback multiple times. You would have to use a vanilla for loop or use some array method like arr.every

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you, it's my bad :(

node-eclib.js Outdated

// Recover all missing fragments one by one.
fragmentIds.forEach(function reconstructEach(id) {
fragmentIds.forEach(function reconstructEach(id, index) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Additionally, if you use an arrow function here you don't have to bind this for context.

Copy link

Choose a reason for hiding this comment

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

Tests are still running on node 0.10 (as can be seen with the CI) since the aim of this library was extensive compatibility. That means no arrow functions. We can probably jump our lowest threshold, but that would be a breaking change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh interesting. I didn't realize that this project was using node 0.10.

@lamphamsy lamphamsy mentioned this pull request Nov 22, 2016
1 task
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

I would like a test confirming that behaviour.

Fragments reconstruction runs in parallel. Hence recovered fragments
could be not in right order.

Fix sort function
@lamphamsy
Copy link
Contributor Author

A reinforced functional test for reconstructing multiple fragments is updated: #43

@lamphamsy lamphamsy added the bug label Nov 22, 2016
@lamphamsy lamphamsy changed the base branch from master to stable November 24, 2017 10:08
@lamphamsy
Copy link
Contributor Author

Merge to working branch

@lamphamsy lamphamsy merged commit b596655 into stable Nov 24, 2017
@lamphamsy lamphamsy deleted the fix/repair_multifrags branch November 24, 2017 10:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants