AvianFlu / ncp

Asynchronous recursive file copying with Node.js.
MIT License
680 stars 103 forks source link

Clobbering files causes duplicate copies and early callback #95

Open maxg opened 9 years ago

maxg commented 9 years ago

Duplicate of issue #71 and others. Existing fixes in PRs #77, #88, and others.

A new fix and test are proposed in PR #94.

Duplicate copies: when clobbering an existing file, onFile does both a remove-and-copy (line 94) and possibly copies the file again depending on modified (line 102).

Early callback: both the call to copyFile on line 95 and one of the later calls to copyFile or cb will increment the number of finished callbacks, with the result that the callback passed to ncp is called too early, before the copy is necessarily completed.