soldair / node-walkdir

Walk a directory tree emitting events based on the contents. API compatable with node-findit. Walk a tree of any depth. Fast! Handles permission errors. Stoppable. windows support. Pull requests are awesome. watchers are appreciated.
MIT License
130 stars 22 forks source link

Directories/Files Sometimes Incorrectly Skipped On Windows #31

Closed pspaulding closed 7 years ago

pspaulding commented 7 years ago

I believe this is related to https://github.com/nodejs/node/issues/12115 I suspect the problem is difficult to duplicate, but it just bit me as the https://github.com/archiverjs/node-archiver library depends on node-walkdir. In my case, I had two different directories that returned the same inode. I traced the problem to line 78-79 of walkdir.js:

      var fileKey = stat.dev + '-' + stat.ino + '-' + fileName;
      if(inos[fileKey] && stat.ino) return;

If I modify line 78 to use path instead of fileName as the last part of the key, the problem is corrected.

      var fileKey = stat.dev + '-' + stat.ino + '-' + path;
soldair commented 7 years ago

thanks for the report. :thinking: i have to think a bit more to make sure we can use this for everything.

pspaulding commented 7 years ago

https://github.com/archiverjs/node-archiver/issues/267#issuecomment-325064961

soldair commented 7 years ago

i pushed a fix that will help. using option track_inodes:false. this was the least invasive andmost useful i think.