You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//if souce modified time greater to target modified time copy file
if(file.mtime.getTime()>stats.mtime.getTime())
copyFile(file,target);
elsereturncb();
});
}
else{
returncb();
}
As we can see, in line 108, cb() can be called before rmFile() and copyFile() finish their jobs. So if target file exists, cb() will be called before file is copied.
The test case below can reproduce the bug:
constdestination=path.join(os.tmpdir(),'bigFile');ncp(someFile,destination,function(err){if(err){returnconsole.error(err);}ncp(someFile,destination,function(err){if(err){returnconsole.error(err);}fs.readFileSync(destination);// Error: ENOENT: no such file or directory, open '/tmp/bigFile'});});
The text was updated successfully, but these errors were encountered:
The bug is caused by following code:
ncp/lib/ncp.js
Lines 89 to 109 in 6820b0f
As we can see, in line 108,
cb()
can be called beforermFile()
andcopyFile()
finish their jobs. So iftarget
file exists,cb()
will be called before file is copied.The test case below can reproduce the bug:
The text was updated successfully, but these errors were encountered: