Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Exists But Receiving ENOENT Error

Here is a gist: https://gist.github.com/973e70bde8e6a530c489

I have two scenarios. One works and one fails even though the code is exactly the same.

  1. Take a CSV file already on the box and parse it. Works perfectly. No issues.
  2. Take a CSV file that was just created and attempt to parse it and I receive:

    ENOENT, no such file or directory '/Users/Home/dev/csv/TwFrI5vhdownload.csv

Same CSV file format and all that. Wouldn't matter anyway because the created file won't even open. It fails with the error above even though the file does exist. If I restart Node and attempt to grab that file, then it works perfectly. If I run fs.stat on the newly created file it fails.

I've tried timeouts, external callbacks, etc.. but with the dynamically created file it always fails.

What am I missing here? Is the file locked and I don't know it?

Thanks!

System:

OSX Lion Node v0.6.7

like image 542
Brandon Avatar asked Nov 14 '22 11:11

Brandon


1 Answers

Are you sure the file is actually created when you try to parse it?

I took a look on the gist and I guess you are downloading the file from somewhere and then parsing it. Without the whole code I can only guess, but I think that you started the download, but you haven't received a clear indication it is there and ready to be parsed.

like image 197
Nikolay Tsenkov Avatar answered Nov 16 '22 02:11

Nikolay Tsenkov