Fix multiple calls to callback when overwriting files#77
Open
jfremy wants to merge 4 commits intoAvianFlu:masterfrom
Open
Fix multiple calls to callback when overwriting files#77jfremy wants to merge 4 commits intoAvianFlu:masterfrom
jfremy wants to merge 4 commits intoAvianFlu:masterfrom
Conversation
There was a problem hiding this comment.
good idea, this will help catch other mis-matches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The logic when overwriting a file seems wrong. If you look at the code path, if clobber is true and modified is false, then there will be a systematic call to cb in the last else statement of onFile.
I've seen the bug in an app of mine that uses ncp but it was hard to trigger and all your unit tests passed.
So I added an additional sanity check in the cb handler that verifies that running is postive or zero and that finished is lower or equal to started.
After doing that, your tests would nearly all fails because of multiple calls to done => which means that one of those invalid situations happened while with the fix in inFile it does work.