Thank you Dan.

Dan Fandrich wrote:
On Thu, Nov 04, 2010 at 01:29:39PM -0400, German Escallon wrote:
My application continuously downloads several XML files through cURL
FTP methods at a certain interval (say once every hour).
Also, another process reads those files and performs operations on
them (read, mv, cp, etc) at a different interval.

Does anyone know if the WRITE_DATA operation is atomic?
In other words.  Is it safe to assume that if I'm downloading file X,
and another process is trying to access X while curl_easy_perform is
writing to it, the other process will not get a corrupted or partial
file? I'm attaching some sample code.  Thank  you in advance.

A server could theoretically send the XML file a byte at a time, spread out
over 20 minutes. Depending on the file size and the libc buffering, the
file on disk could slowly increase in size by the same amount. If you're
concerned that clients not have access to the file as it's thus written,
then you'll have to take explicit steps to avoid it.  The obvious ways
would be to lock the file as it's downloading, or download it to a temporary
location then atomically move it into the right location once it's complete.

Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to