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
The test case to reproduce the bug is similar to #144 but with a slight difference:
consthash1=crypto.createHash('sha1');consthash2=crypto.createHash('sha1');constdestination=path.join(os.tmpdir(),'bigFile');constbigFile1='/path/to/file1';constbigFile2='/path/to/file2';constfile1Content=fs.readFileSync(bigFile1);constoriginal1Hash=hash1.update(file1Content).digest();constfile2Content=fs.readFileSync(bigFile2);constoriginal2Hash=hash2.update(file2Content).digest();fs.rmSync(destination,{recursive: true,force: true});// operation Ancp(bigFile1,destination,function(err){if(err){returnconsole.error(err);}consthash=crypto.createHash('sha1');constcopiedBigFile=destination;constcopiedFileContext=fs.readFileSync(copiedBigFile);constcopiedHash=hash.update(copiedFileContext).digest();// AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy valueassert.ok(original1Hash.equals(copiedHash));// WTF, destination is not bigFile1!});setTimeout(()=>{ncp(bigFile2,destination,function(err){if(err){returnconsole.error(err);}// deal with the bug in #143setTimeout(()=>{consthash=crypto.createHash('sha1');constcopiedBigFile=destination;constcopiedFileContext=fs.readFileSync(copiedBigFile);constcopiedHash=hash.update(copiedFileContext).digest();assert.ok(original2Hash.equals(copiedHash));},1000)});},100);// a small delay here
The text was updated successfully, but these errors were encountered:
Before copying a file, ncp first checks whether the target file exists. If it exists (writable is false), ncp will delete it and start copying.
ncp/lib/ncp.js
Lines 89 to 97 in 6820b0f
But the deleted file may be the file being copied by another ncp call at the same time, causing strange behavior.
ncp/lib/ncp.js
Lines 113 to 126 in 6820b0f
The test case to reproduce the bug is similar to #144 but with a slight difference:
The text was updated successfully, but these errors were encountered: