How do I know when a file is fully created

Hi,

I have a rails app, that lets user submit data. I use the data to tell another app to create a file. I can't get this app to tell me when it is finished with the file. So is there any way in Rails to check if another app is writing to a file?

Kind regards, Dave.

I have a rails app, that lets user submit data. I use the data to tell another app to create a file. I can't get this app to tell me when it is finished with the file. So is there any way in Rails to check if another app is writing to a file?

There's probably a way... the unix command lsof will report that sort of thing to you, but to check on files you don't own requires you to be root.

So maybe not.

I had to do something similar, but for remote web files. I ended up making HEAD requests and comparing the file size over a period of time. Once it stopped changing I'd consider the file ready.

You maybe could do something similar.

Or change the process so your second app doesn't see the file until it's ready. That is, first app writes out "file.tmp" and at the very end moves it to "file" and second app only looks for "file" or something.